summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm
diff options
context:
space:
mode:
authorJocelyn Falempe <jfalempe@redhat.com>2024-04-26 14:10:50 +0200
committerMaarten Lankhorst <maarten.lankhorst@linux.intel.com>2024-05-02 23:39:21 +0200
commit514ca22a25265e9bef10eab143e6a956b00694aa (patch)
tree0754be7f0c56b56fbe76c5685ab9ea76e5d0f9e7 /drivers/gpu/drm
parent87cb4a612a89690b123e68f6602d9f6581b03597 (diff)
downloadlinux-stable-514ca22a25265e9bef10eab143e6a956b00694aa.tar.gz
linux-stable-514ca22a25265e9bef10eab143e6a956b00694aa.tar.bz2
linux-stable-514ca22a25265e9bef10eab143e6a956b00694aa.zip
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>
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r--drivers/gpu/drm/drm_fb_dma_helper.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_fb_dma_helper.c b/drivers/gpu/drm/drm_fb_dma_helper.c
index 96e5ab960f12..e1d61a65210b 100644
--- a/drivers/gpu/drm/drm_fb_dma_helper.c
+++ b/drivers/gpu/drm/drm_fb_dma_helper.c
@@ -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 -EINVAL;
+
fb = plane->state->fb;
/* Only support linear modifier */
if (fb->modifier != DRM_FORMAT_MOD_LINEAR)