Skip to contentSkip to conversation

gpu/drm/virtio: fix error return in vgdev_output_init()

PATCH Applied Alexandr Sapozhnkiov 2 participants 3 messages Sep 22, 2025 – Oct 9, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpu/drm/virtio: fix error return in vgdev_output_init()

From: Alexandr Sapozhnikov <[email protected]>

Return value of function drm_crtc_init_with_planes(), called at virtgpu_display.c:276, is not checked, but it is usually checked for this function

Found by Linux Verification Center (linuxtesting.org) with SVACE.

---
 drivers/gpu/drm/virtio/virtgpu_display.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/virtio/virtgpu_display.c +4 -1
index ad924a8502e9..59b652e8a630 100644
@@ -253,6 +253,7 @@ static const struct drm_connector_funcs virtio_gpu_connector_funcs = {
 
 static int vgdev_output_init(struct virtio_gpu_device *vgdev, int index)
 {
+	int ret;
 	struct drm_device *dev = vgdev->ddev;
 	struct virtio_gpu_output *output = vgdev->outputs + index;
 	struct drm_connector *connector = &output->conn;
@@ -273,8 +274,10 @@ static int vgdev_output_init(struct virtio_gpu_device *vgdev, int index)
 	cursor = virtio_gpu_plane_init(vgdev, DRM_PLANE_TYPE_CURSOR, index);
 	if (IS_ERR(cursor))
 		return PTR_ERR(cursor);
-	drm_crtc_init_with_planes(dev, crtc, primary, cursor,
+	ret = drm_crtc_init_with_planes(dev, crtc, primary, cursor,
 				  &virtio_gpu_crtc_funcs, NULL);
+	if (ret)
+		return ret;
 	drm_crtc_helper_add(crtc, &virtio_gpu_crtc_helper_funcs);
 
 	drm_connector_init(dev, connector, &virtio_gpu_connector_funcs,
Signature · 1 line
2.43.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 26 lines · Alexandr Sapozhnkiov

From: Alexandr Sapozhnikov <[email protected]>

Return value of function drm_crtc_init_with_planes(), called at virtgpu_display.c:276, is not checked, but it is usually checked for this function

Found by Linux Verification Center (linuxtesting.org) with SVACE.

---
 drivers/gpu/drm/virtio/virtgpu_display.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/virtio/virtgpu_display.c +1 -0
index ad924a8502e9..59b652e8a630 100644
@@ -253,6 +253,7 @@ static const struct drm_connector_funcs virtio_gpu_connector_funcs = {
 
 static int vgdev_output_init(struct virtio_gpu_device *vgdev, int index)
 {
+	int ret;
 	struct drm_device *dev = vgdev->ddev;
 	struct virtio_gpu_output *output = vgdev->outputs + index;
 	struct drm_connector *connector = &output->conn;
@@ -273,8 +274,10 @@ static int vgdev_output_init(struct virtio_gpu_device *vgdev, int index)
 	cursor = virtio_gpu_plane_init(vgdev, DRM_PLANE_TYPE_CURSOR, index);

drivers/gpu/drm/virtio/virtgpu_display.c static int vgdev_output_init(struct virtio_gpu_device *vgdev, int index) · line 283

Quoted 10 lines
drivers/gpu/drm/virtio/virtgpu_display.c +3 -1
 	if (IS_ERR(cursor))
 		return PTR_ERR(cursor);
-	drm_crtc_init_with_planes(dev, crtc, primary, cursor,
+	ret = drm_crtc_init_with_planes(dev, crtc, primary, cursor,
 				  &virtio_gpu_crtc_funcs, NULL);
+	if (ret)
+		return ret;
 	drm_crtc_helper_add(crtc, &virtio_gpu_crtc_helper_funcs);
 
 	drm_connector_init(dev, connector, &virtio_gpu_connector_funcs,

Patch will need a cosmetic correction for the indentation that I'll change while applying, thanks.

Signature · 2 lines
Best regards,
Dmitry
maintainer Applied
#2 lore raw
In reply to Alexandr Sapozhnkiov

drivers/gpu/drm/virtio/virtgpu_display.c static const struct drm_connector_funcs virtio_gpu_connector_funcs = {

Quoted 17 lines · Alexandr Sapozhnkiov

From: Alexandr Sapozhnikov <[email protected]>

Return value of function drm_crtc_init_with_planes(), called at virtgpu_display.c:276, is not checked, but it is usually checked for this function

Found by Linux Verification Center (linuxtesting.org) with SVACE.

---
 drivers/gpu/drm/virtio/virtgpu_display.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/virtio/virtgpu_display.c +0 -0
index ad924a8502e9..59b652e8a630 100644
@@ -253,6 +253,7 @@ static const struct drm_connector_funcs virtio_gpu_connector_funcs = {

Applied to misc-next with corrected coding style and edited commit message, thanks.

Signature · 2 lines
Best regards,
Dmitry