Skip to contentSkip to conversation

drivers/firmware: Add missing platform_device_put() in sysfb_create_simplefb

PATCH Superseded Miaoqian Lin 3 participants 5 messages Dec 31, 2021 – Feb 4, 2022 DRM driver for firmware framebuffers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/firmware: Add missing platform_device_put() in sysfb_create_simplefb

Add the missing platform_device_put() before return from sysfb_create_simplefb() in the error handling case.

Fixes 8633ef8 ("drivers/firmware: consolidate EFI framebuffer setup for all arches")
---
 drivers/firmware/sysfb_simplefb.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/firmware/sysfb_simplefb.c +6 -2
index b86761904949..303a491e520d 100644
@@ -113,12 +113,16 @@ __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)
+	if (ret) {
+		platform_device_put(pd);
 		return ret;
+	}
 
 	ret = platform_device_add_data(pd, mode, sizeof(*mode));
-	if (ret)
+	if (ret) {
+		platform_device_put(pd);
 		return ret;
+	}
 
 	return platform_device_add(pd);
 }
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 1/1
#1 lore raw

Hello Miaoqian,

Quoted 6 lines · Miaoqian Lin

Add the missing platform_device_put() before return from sysfb_create_simplefb() in the error handling case.

Fixes 8633ef8 ("drivers/firmware: consolidate EFI framebuffer setup for all arches")

---

Thanks for the patch.

Quoted 14 lines
 drivers/firmware/sysfb_simplefb.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/firmware/sysfb_simplefb.c +2 -1
index b86761904949..303a491e520d 100644
@@ -113,12 +113,16 @@ __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)
+	if (ret) {
+		platform_device_put(pd);

drivers/firmware/sysfb_simplefb.c __init int sysfb_create_simplefb(const struct screen_info *si, · line 126

Quoted 10 lines
drivers/firmware/sysfb_simplefb.c +4 -1
 		return ret;
+	}
 
 	ret = platform_device_add_data(pd, mode, sizeof(*mode));
-	if (ret)
+	if (ret) {
+		platform_device_put(pd);
 		return ret;
+	}
 

To avoid duplicating the error code logic twice, you could also do:

	if (ret)
		goto pdev_put;

drivers/firmware/sysfb_simplefb.c __init int sysfb_create_simplefb(const struct screen_info *si, · line 127

Quoted 1 line
drivers/firmware/sysfb_simplefb.c +0 -0
 	return platform_device_add(pd);

and then after this return statement:

pdev_put:

	platform_device_put(pd);
	return ret;

Best regards,

Signature · 3 lines
Javier Martinez Canillas
Linux Engineering
Red Hat
#2 lore raw

PATCH v2 1/1 drivers/firmware: Add missing platform_device_put() in sysfb_create_simplefb

Add the missing platform_device_put() before return from sysfb_create_simplefb() in the error handling case.

Fixes 8633ef8 ("drivers/firmware: consolidate EFI framebuffer setup for all arches")

---
Changes in v2:
- Use goto label to avoid duplicating the error code logic.

---
 drivers/firmware/sysfb_simplefb.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/firmware/sysfb_simplefb.c +6 -2
index b86761904949..46d776c29174 100644
@@ -114,11 +114,15 @@ __init int sysfb_create_simplefb(const struct screen_info *si,
 
 	ret = platform_device_add_resources(pd, &res, 1);
 	if (ret)
-		return ret;
+		goto pdev_put;
 
 	ret = platform_device_add_data(pd, mode, sizeof(*mode));
 	if (ret)
-		return ret;
+		goto pdev_put;
 
 	return platform_device_add(pd);
+
+pdev_put:
+	platform_device_put(pd);
+	return ret;
 }
Signature · 1 line
2.17.1
maintainer Reviewed-by on v2 1/1
#3 lore raw
Quoted 12 lines · Miaoqian Lin

Add the missing platform_device_put() before return from sysfb_create_simplefb() in the error handling case.

Fixes 8633ef8 ("drivers/firmware: consolidate EFI framebuffer setup for all arches")

---
Changes in v2:
- Use goto label to avoid duplicating the error code logic.

---
 drivers/firmware/sysfb_simplefb.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Best regards,

Signature · 3 lines
Javier Martinez Canillas
Linux Engineering
Red Hat
#4 lore raw
Quoted 14 lines · Javier Martinez Canillas
Quoted 12 lines · Miaoqian Lin

Add the missing platform_device_put() before return from sysfb_create_simplefb() in the error handling case.

Fixes 8633ef8 ("drivers/firmware: consolidate EFI framebuffer setup for all arches")

---
Changes in v2:
- Use goto label to avoid duplicating the error code logic.

---
 drivers/firmware/sysfb_simplefb.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
Quoted 1 line

Does not apply to my tree :(