[PATCH -next] [ARM] am300epd: Release platform device in case of platform_device_add_data() fails
Lin Yujun
linyujun809 at huawei.com
Tue Sep 13 20:34:55 PDT 2022
The platform device need to be released when platform_device_add_data()
fails. Use platform_device_put() to release 'pdev' in error path.
Fixes: 4ce255c1420d ("[ARM] 5354/1: mach-pxa: add AM300 platform driver v3")
Signed-off-by: Lin Yujun <linyujun809 at huawei.com>
---
arch/arm/mach-pxa/am300epd.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-pxa/am300epd.c b/arch/arm/mach-pxa/am300epd.c
index 4b55bc89db8f..f8542b6aa9b7 100644
--- a/arch/arm/mach-pxa/am300epd.c
+++ b/arch/arm/mach-pxa/am300epd.c
@@ -275,11 +275,14 @@ int __init am300_init(void)
return -ENOMEM;
/* the am300_board that will be seen by broadsheetfb is a copy */
- platform_device_add_data(am300_device, &am300_board,
+ ret = platform_device_add_data(am300_device, &am300_board,
sizeof(am300_board));
+ if (ret) {
+ platform_device_put(am300_device);
+ return ret;
+ }
ret = platform_device_add(am300_device);
-
if (ret) {
platform_device_put(am300_device);
return ret;
--
2.17.1
More information about the linux-arm-kernel
mailing list