Skip to content

Commit

Permalink
drm/client: Prevent NULL dereference in drm_client_buffer_delete()
Browse files Browse the repository at this point in the history
The drm_gem_vunmap() will crash with a NULL dereference if the passed
object pointer is NULL. It wasn't a problem before we added the locking
support to drm_gem_vunmap function because the mapping argument was always
NULL together with the object. Make drm_client_buffer_delete() to check
whether GEM is NULL before trying to unmap the GEM, it will happen on
framebuffer creation error.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Link: https://lore.kernel.org/dri-devel/Y1kFEGxT8MVlf32V@kili/
Fixes: 79e2cf2 ("drm/gem: Take reservation lock for vmap/vunmap operations")
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20221030154412.8320-3-dmitry.osipenko@collabora.com
  • Loading branch information
Dmitry Osipenko committed Nov 2, 2022
1 parent d3292da commit 444bbba
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/gpu/drm/drm_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,10 @@ static void drm_client_buffer_delete(struct drm_client_buffer *buffer)
{
struct drm_device *dev = buffer->client->dev;

drm_gem_vunmap_unlocked(buffer->gem, &buffer->map);

if (buffer->gem)
if (buffer->gem) {
drm_gem_vunmap_unlocked(buffer->gem, &buffer->map);
drm_gem_object_put(buffer->gem);
}

if (buffer->handle)
drm_mode_destroy_dumb(dev, buffer->handle, buffer->client->file);
Expand Down

0 comments on commit 444bbba

Please sign in to comment.