Skip to contentSkip to conversation

firmware: sysfb: fix platform-device leak in error path

PATCH Superseded Johan Hovold 1 participant 1 message Mar 3, 2022

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

PATCH 1/1 firmware: sysfb: fix platform-device leak in error path

Make sure to free the platform device also in the unlikely event that registration fails.

Fixes 0589e8889dce ("drivers/firmware: Add missing platform_device_put() in sysfb_create_simplefb")
Fixes 8633ef82f101 ("drivers/firmware: consolidate EFI framebuffer setup for all arches")
Cc Miaoqian Lin <[email protected]>
Cc Javier Martinez Canillas <[email protected]>
---
 drivers/firmware/sysfb_simplefb.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)
drivers/firmware/sysfb_simplefb.c +14 -9
index 303a491e520d..757cc8b9f3de 100644
@@ -113,16 +113,21 @@ __init int sysfb_create_simplefb(const struct screen_info *si,
 	sysfb_apply_efi_quirks(pd);
 
 	ret = platform_device_add_resources(pd, &res, 1);
-	if (ret) {
-		platform_device_put(pd);
-		return ret;
-	}
+	if (ret)
+		goto err_put_device;
 
 	ret = platform_device_add_data(pd, mode, sizeof(*mode));
-	if (ret) {
-		platform_device_put(pd);
-		return ret;
-	}
+	if (ret)
+		goto err_put_device;
+
+	ret = platform_device_add(pd);
+	if (ret)
+		goto err_put_device;
+
+	return 0;
+
+err_put_device:
+	platform_device_put(pd);
 
-	return platform_device_add(pd);
+	return ret;
 }
Signature · 1 line
2.34.1