drm/fb_dma: Add checks in drm_fb_dma_get_scanout_buffer()
Subsystems (2)
PATCH 1/1 drm/fb_dma: Add checks in drm_fb_dma_get_scanout_buffer()
plane->state and plane->state->fb can be NULL, so add a check before dereferencing them.
Found by testing with the imx driver.
--- drivers/gpu/drm/drm_fb_dma_helper.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/drm_fb_dma_helper.c +3 -0
@@ -167,6 +167,9 @@ int drm_fb_dma_get_scanout_buffer(struct drm_plane *plane,struct drm_gem_dma_object *dma_obj;struct drm_framebuffer *fb; +if (!plane->state || !plane->state->fb) +return -ENODEV ; + fb = plane->state->fb;/* Only support linear modifier */ if (fb->modifier !=DRM_FORMAT_MOD_LINEAR )
base-commit: 2e3f08a1ac99cb9a19a5cb151593d4f9df5cc6a7
Signature · 1 line
2.44.0
Am 26.04.24 um 14:10 schrieb Jocelyn Falempe:
Quoted 15 lines
plane->stateandplane->state->fbcan be NULL, so add a check before dereferencing them.
Found by testing with the imx driver.Fixes 879b3b6511fe9 ("drm/fb_dma: Add generic get_scanout_buffer() for drm_panic")Signed-off-by Jocelyn Falempe <[email protected]>--- drivers/gpu/drm/drm_fb_dma_helper.c | 3 +++ 1 file changed, 3 insertions(+)drivers/gpu/drm/drm_fb_dma_helper.c +0
-0
drivers/gpu/drm/drm_fb_dma_helper.c int drm_fb_dma_get_scanout_buffer(struct drm_plane *plane, · line 172
Quoted 6 lines
drivers/gpu/drm/drm_fb_dma_helper.c +3
-0@@ -167,6 +167,9 @@ int drm_fb_dma_get_scanout_buffer(struct drm_plane *plane,struct drm_gem_dma_object *dma_obj;struct drm_framebuffer *fb; +if (!plane->state || !plane->state->fb) +return -ENODEV ; +
It's EINVAL here. With that fixed, free free to add
Best regards
Thomas
Quoted 5 lines
drivers/gpu/drm/drm_fb_dma_helper.c +0
-0fb = plane->state->fb;/* Only support linear modifier */ if (fb->modifier !=DRM_FORMAT_MOD_LINEAR )base-commit:
2e3f08a1ac99cb9a19a5cb151593d4f9df5cc6a7
Signature · 7 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nuernberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg)
Quoted 13 lines · Thomas Zimmermann
Am 26.04.24 um 14:10 schrieb Jocelyn Falempe:
Quoted 10 lines
plane->stateandplane->state->fbcan be NULL, so add a check before dereferencing them.
Found by testing with the imx driver.Fixes 879b3b6511fe9 ("drm/fb_dma: Add generic get_scanout_buffer() for drm_panic")Signed-off-by Jocelyn Falempe <[email protected]>---
drivers/gpu/drm/drm_fb_dma_helper.c| 3 +++1 file changed, 3 insertions(+)
Quoted 13 lines
drivers/gpu/drm/drm_fb_dma_helper.c int drm_fb_dma_get_scanout_buffer(struct drm_plane · line 172
Quoted 11 lines
drivers/gpu/drm/drm_fb_dma_helper.c +3
-0@@ -167,6 +167,9 @@ int drm_fb_dma_get_scanout_buffer(struct drm_plane *plane, struct drm_gem_dma_object *dma_obj; struct drm_framebuffer *fb; + if (!plane->state || !plane->state->fb) + return -ENODEV; +It's EINVAL here. With that fixed, free free to add
Thanks, I just merged it to drm-misc-next with that fixed.
Quoted 12 lines
Reviewed-by Thomas Zimmermann <[email protected]>Best regards
ThomasQuoted 5 lines
drivers/gpu/drm/drm_fb_dma_helper.c +0
-0fb = plane->state->fb; /* Only support linear modifier */ if (fb->modifier != DRM_FORMAT_MOD_LINEAR)base-commit:
2e3f08a1ac99cb9a19a5cb151593d4f9df5cc6a7
Signature · 1 line
Jocelyn