qemu-arm
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] hw/display/omap_lcdc: Fix potential NULL pointer dereference


From: AlexChen
Subject: Re: [PATCH] hw/display/omap_lcdc: Fix potential NULL pointer dereference
Date: Sat, 31 Oct 2020 11:01:21 +0800
User-agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20130509 Thunderbird/17.0.6

On 2020/10/30 22:35, Peter Maydell wrote:
> On Fri, 30 Oct 2020 at 14:29, Peter Maydell <peter.maydell@linaro.org> wrote:
>>
>> On Fri, 30 Oct 2020 at 10:23, AlexChen <alex.chen@huawei.com> wrote:
>>>
>>> In omap_lcd_interrupts(), the pointer omap_lcd is dereferenced before
>>> being check if it is valid, which may lead to NULL pointer dereference.
>>> So move the assignment to surface after checking that the omap_lcd is valid.
>>>
>>> Reported-by: Euler Robot <euler.robot@huawei.com>
>>> Signed-off-by: Alex Chen <alex.chen@huawei.com>
>>> ---
>>>  hw/display/omap_lcdc.c | 3 ++-
>>>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
>> Applied to target-arm.next, thanks.
> 
> Whoops, spoke too soon. This doesn't compile:
> 
> ../../hw/display/omap_lcdc.c: In function ‘omap_update_display’:
> ../../hw/display/omap_lcdc.c:88:10: error: ‘surface’ may be used
> uninitialized in this function [-Werror=maybe-uninitialized]
>          !surface_bits_per_pixel(surface)) {
>           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> 
> because the early exit check
>     if (!omap_lcd || omap_lcd->plm == 1 || !omap_lcd->enable ||
>         !surface_bits_per_pixel(surface)) {
>         return;
>     }
> 
> uses 'surface' and this patch moves the initialization of that
> variable down below its first use.
> 

Oh, I apologize for this compilation error, I will fix it in my patch v2.

Thanks,
Alex



reply via email to

[Prev in Thread] Current Thread [Next in Thread]