hw/display/exynos4210_fimd: Fix potential NULL pointer dereference
PATCH v2 1/1 hw/display/exynos4210_fimd: Fix potential NULL pointer dereference
In exynos4210_fimd_update(), the pointer s is dereferinced before being check if it is valid, which may lead to NULL pointer dereference. So move the assignment to global_width after checking that the s is valid.
--- hw/display/exynos4210_fimd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
hw/display/exynos4210_fimd.c +3 -1
@@ -1275,12 +1275,14 @@ static void exynos4210_fimd_update(void *opaque)bool blend = false;uint8_t *host_fb_addr;bool is_dirty = false; -const int global_width = (s->vidtcon[2 ] &FIMD_VIDTCON2_SIZE_MASK ) +1 ; +int global_width;if (!s || !s->console || !s->enabled ||surface_bits_per_pixel (qemu_console_surface (s->console)) ==0 ) {return ; } + + global_width = (s->vidtcon[2 ] &FIMD_VIDTCON2_SIZE_MASK ) +1 ;exynos4210_update_resolution (s); surface =qemu_console_surface (s->console);
Signature · 1 line
2.19.1
Quoted 1 line · AlexChen
In
exynos4210_fimd_update(), the pointer s is dereferinced before
Typo dereferinced -> dereferenced.
Quoted 2 lines
being check if it is valid, which may lead to NULL pointer dereference. So move the assignment to
global_widthafter checking that the s is valid.
Easier to read "after checking 's' is valid."
Quoted 6 lines
Reported-by Euler Robot <[email protected]>Signed-off-by Alex Chen <[email protected]>--- hw/display/exynos4210_fimd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Quoted 11 lines · Philippe Mathieu-Daudé
Quoted 1 line · AlexChen
In
exynos4210_fimd_update(), the pointer s is dereferinced beforeTypo dereferinced -> dereferenced.
Quoted 2 lines
being check if it is valid, which may lead to NULL pointer dereference. So move the assignment to
global_widthafter checking that the s is valid.Easier to read "after checking 's' is valid."
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Reported-by Euler Robot <[email protected]>Signed-off-by Alex Chen <[email protected]>--- hw/display/exynos4210_fimd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Thanks for your review, I will fix it in my patch V3.
Thanks,
Alex
PATCH v3 1/1 hw/display/exynos4210_fimd: Fix potential NULL pointer dereference
In reply to Philippe Mathieu-DaudéIn exynos4210_fimd_update(), the pointer 's' is dereferenced before checking it is valid, which may lead to NULL pointer dereference. So move the assignment to global_width after checking 's' is valid.
--- hw/display/exynos4210_fimd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
hw/display/exynos4210_fimd.c +3 -1
@@ -1275,12 +1275,14 @@ static void exynos4210_fimd_update(void *opaque)bool blend = false;uint8_t *host_fb_addr;bool is_dirty = false; -const int global_width = (s->vidtcon[2 ] &FIMD_VIDTCON2_SIZE_MASK ) +1 ; +int global_width;if (!s || !s->console || !s->enabled ||surface_bits_per_pixel (qemu_console_surface (s->console)) ==0 ) {return ; } + + global_width = (s->vidtcon[2 ] &FIMD_VIDTCON2_SIZE_MASK ) +1 ;exynos4210_update_resolution (s); surface =qemu_console_surface (s->console);
Signature · 1 line
2.19.1
Peter Maydell
AppliedQuoted 11 lines · AlexChen
In
exynos4210_fimd_update(), the pointer 's' is dereferenced before checking it is valid, which may lead to NULL pointer dereference. So move the assignment toglobal_widthafter checking 's' is valid.Reported-by Euler Robot <[email protected]>Signed-off-by Alex Chen <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>--- hw/display/exynos4210_fimd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Applied to target-arm.next, thanks.
-- PMM