Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Fixes: 879b3b6511fe ("drm/fb_dma: Add generic get_scanout_buffer() for drm_panic")
Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20240426121121.241366-1-jfalempe@redhat.com
(cherry picked from commit 986c12d8c9a677c094c37bd6aa636b4d4c5ccd46)
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>

authored by

Jocelyn Falempe and committed by
Maarten Lankhorst
514ca22a 87cb4a61

+3
+3
drivers/gpu/drm/drm_fb_dma_helper.c
··· 167 167 struct drm_gem_dma_object *dma_obj; 168 168 struct drm_framebuffer *fb; 169 169 170 + if (!plane->state || !plane->state->fb) 171 + return -EINVAL; 172 + 170 173 fb = plane->state->fb; 171 174 /* Only support linear modifier */ 172 175 if (fb->modifier != DRM_FORMAT_MOD_LINEAR)