drm/virtio: Fix a NULL vs ERR_PTR() bug in virtio_gpu_user_framebuffer_create()
Subsystems (5)
PATCH 1/1 drm/virtio: Fix a NULL vs ERR_PTR() bug in virtio_gpu_user_framebuffer_create()
Smatch complains that returning a NULL here will lead to a NULL pointer dereference in drm_mode_addfb2(). Return an error pointer instead.
---
This code is obviously over a decade old. I think this patch is correct. None of the other implementations return NULL, but I haven't tested it.
--- drivers/gpu/drm/virtio/virtgpu_display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/virtio/virtgpu_display.c +1 -1
@@ -344,7 +344,7 @@ virtio_gpu_user_framebuffer_create(struct drm_device *dev,if (ret) {kfree (virtio_gpu_fb);drm_gem_object_put (obj); -return NULL ; +return ERR_PTR (ret); }return &virtio_gpu_fb->base;
Signature · 1 line
2.53.0
Quoted 17 lines · Dan Carpenter
Smatch complains that returning a NULL here will lead to a NULL pointer dereference in
drm_mode_addfb2(). Return an error pointer instead.Fixes dc5698e80cf7 ("Add virtio gpu driver.")Signed-off-by Dan Carpenter <[email protected]>---
This code is obviously over a decade old. I think this patch is correct. None of the other implementations return NULL, but I haven't tested it.--- drivers/gpu/drm/virtio/virtgpu_display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/virtio/virtgpu_display.c +0
-0
drivers/gpu/drm/virtio/virtgpu_display.c virtio_gpu_user_framebuffer_create(struct drm_device *dev, · line 350
Quoted 8 lines
drivers/gpu/drm/virtio/virtgpu_display.c +1
-1@@ -344,7 +344,7 @@ virtio_gpu_user_framebuffer_create(struct drm_device *dev,if (ret) {kfree (virtio_gpu_fb);drm_gem_object_put (obj); -return NULL ; +return ERR_PTR (ret); }return &virtio_gpu_fb->base;
Applied to drm-misc-fixes, thanks!
Signature · 2 lines
Best regards, Dmitry