[PATCH 5.18 075/879] drm/komeda: return early if drm_universal_plane_init() fails.

From: Greg Kroah-Hartman
Date: Tue Jun 07 2022 - 18:07:15 EST


From: Liviu Dudau <liviu.dudau@xxxxxxx>

[ Upstream commit c8f76c37cc3668ee45e081e76a15f24a352ebbdd ]

If drm_universal_plane_init() fails early we jump to the common cleanup code
that calls komeda_plane_destroy() which in turn could access the uninitalised
drm_plane and crash. Return early if an error is detected without going through
the common code.

Reported-by: Steven Price <steven.price@xxxxxxx>
Reviewed-by: Steven Price <steven.price@xxxxxxx>
Signed-off-by: Liviu Dudau <liviu.dudau@xxxxxxx>
Link: https://lore.kernel.org/dri-devel/20211203100946.2706922-1-liviu.dudau@xxxxxxx
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
drivers/gpu/drm/arm/display/komeda/komeda_plane.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_plane.c b/drivers/gpu/drm/arm/display/komeda/komeda_plane.c
index d63d83800a8a..d646e3ae1a23 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_plane.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_plane.c
@@ -275,8 +275,10 @@ static int komeda_plane_add(struct komeda_kms_dev *kms,

komeda_put_fourcc_list(formats);

- if (err)
- goto cleanup;
+ if (err) {
+ kfree(kplane);
+ return err;
+ }

drm_plane_helper_add(plane, &komeda_plane_helper_funcs);

--
2.35.1