* [PATCH] drm/virtio: Fix a NULL vs ERR_PTR() bug in virtio_gpu_user_framebuffer_create()
@ 2026-08-13 7:08 Dan Carpenter
2026-08-14 13:42 ` Dmitry Osipenko
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2026-08-13 7:08 UTC (permalink / raw)
To: Dave Airlie
Cc: David Airlie, Gerd Hoffmann, Dmitry Osipenko, Gurchetan Singh,
Chia-I Wu, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
Simona Vetter, Michael S. Tsirkin, dri-devel, virtualization,
linux-kernel, kernel-janitors
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 <error27@gmail.com>
---
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(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c b/drivers/gpu/drm/virtio/virtgpu_display.c
index 44ffffec550f..85ea252c658e 100644
--- a/drivers/gpu/drm/virtio/virtgpu_display.c
+++ b/drivers/gpu/drm/virtio/virtgpu_display.c
@@ -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;
--
2.53.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/virtio: Fix a NULL vs ERR_PTR() bug in virtio_gpu_user_framebuffer_create()
2026-08-13 7:08 [PATCH] drm/virtio: Fix a NULL vs ERR_PTR() bug in virtio_gpu_user_framebuffer_create() Dan Carpenter
@ 2026-08-14 13:42 ` Dmitry Osipenko
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Osipenko @ 2026-08-14 13:42 UTC (permalink / raw)
To: Dan Carpenter, Dave Airlie
Cc: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
Simona Vetter, Michael S. Tsirkin, dri-devel, virtualization,
linux-kernel, kernel-janitors
On 8/13/26 10:08, Dan Carpenter wrote:
> 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 <error27@gmail.com>
> ---
> 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(-)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c b/drivers/gpu/drm/virtio/virtgpu_display.c
> index 44ffffec550f..85ea252c658e 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_display.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_display.c
> @@ -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!
--
Best regards,
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-14 13:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-13 7:08 [PATCH] drm/virtio: Fix a NULL vs ERR_PTR() bug in virtio_gpu_user_framebuffer_create() Dan Carpenter
2026-08-14 13:42 ` Dmitry Osipenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®