[PATCH v7 13/43] drm/vkms: Add error handling in plane config creation

From: Louis Chauvet

Date: Thu Nov 26 2026 - 06:30:37 EST


Properly route the error path of vkms_config_create_plane() through a
fail label to simplify future work.

Signed-off-by: Louis Chauvet <louis.chauvet@xxxxxxxxxxx>
---
drivers/gpu/drm/vkms/vkms_config.c | 12 +++++++++---
drivers/gpu/drm/vkms/vkms_config.h | 2 +-
2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
index 8cd4fe6551fb..c5d90f7e934a 100644
--- a/drivers/gpu/drm/vkms/vkms_config.c
+++ b/drivers/gpu/drm/vkms/vkms_config.c
@@ -421,13 +421,16 @@ void vkms_config_register_debugfs(struct vkms_device *vkms_device)
ARRAY_SIZE(vkms_config_debugfs_list));
}

-struct vkms_config_plane *vkms_config_create_plane(struct vkms_config *config)
+struct vkms_config_plane __must_check *vkms_config_create_plane(struct vkms_config *config)
{
struct vkms_config_plane *plane_cfg;
+ int ret;

plane_cfg = kzalloc_obj(*plane_cfg);
- if (!plane_cfg)
- return ERR_PTR(-ENOMEM);
+ if (!plane_cfg) {
+ ret = -ENOMEM;
+ goto fail;
+ }

plane_cfg->config = config;
plane_cfg->default_pipeline = false;
@@ -437,6 +440,9 @@ struct vkms_config_plane *vkms_config_create_plane(struct vkms_config *config)
list_add_tail_rcu(&plane_cfg->link, &config->planes);

return plane_cfg;
+
+fail:
+ return ERR_PTR(ret);
}
EXPORT_SYMBOL_IF_KUNIT(vkms_config_create_plane);

diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
index 95e5c3694742..8f038562afd4 100644
--- a/drivers/gpu/drm/vkms/vkms_config.h
+++ b/drivers/gpu/drm/vkms/vkms_config.h
@@ -314,7 +314,7 @@ void vkms_config_register_debugfs(struct vkms_device *vkms_device);
* The new plane configuration or an error. Call vkms_config_destroy_plane() to
* free the returned plane configuration.
*/
-struct vkms_config_plane *vkms_config_create_plane(struct vkms_config *config);
+struct vkms_config_plane __must_check *vkms_config_create_plane(struct vkms_config *config);

/**
* vkms_config_destroy_plane() - Remove and free a plane configuration

--
2.56.0