mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH -next] ARM pxa2xx: Add missing platform_device_put() in pxa2xx_set_spi_info()
@ 2022-09-14  3:33 Lin Yujun
  2022-09-26  9:14 ` linyujun (C)
  0 siblings, 1 reply; 2+ messages in thread
From: Lin Yujun @ 2022-09-14  3:33 UTC (permalink / raw)
  To: daniel, haojian.zhuang, robert.jarzmik, linux, lg, eric.miao
  Cc: linux-arm-kernel, linux-kernel

In error case in pxa2xx_set_spi_info() after calling
platform_device_add(), the failed 'pdev' need to be
release or it will be leak, call platform_device_put()
to fix this problem.

Fixes: e172274ccc55 ("[ARM] 5088/3: pxa2xx: add pxa2xx_set_spi_info to register pxa2xx-spi platform devices")
Signed-off-by: Lin Yujun <linyujun809@huawei.com>
---
 arch/arm/mach-pxa/devices.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-pxa/devices.c b/arch/arm/mach-pxa/devices.c
index a7b92dd1ca9e..2727f0138758 100644
--- a/arch/arm/mach-pxa/devices.c
+++ b/arch/arm/mach-pxa/devices.c
@@ -1087,7 +1087,11 @@ void __init pxa2xx_set_spi_info(unsigned id, struct pxa2xx_spi_controller *info)
 	}
 
 	pd->dev.platform_data = info;
-	platform_device_add(pd);
+	if (platform_device_add(pd)) {
+		printk(KERN_ERR "pxa2xx-spi: failed to add platform device %d\n",
+			id);
+		platform_device_put(pd);
+	}
 }
 
 static struct resource pxa_dma_resource[] = {
-- 
2.17.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH -next] ARM pxa2xx: Add missing platform_device_put() in pxa2xx_set_spi_info()
  2022-09-14  3:33 [PATCH -next] ARM pxa2xx: Add missing platform_device_put() in pxa2xx_set_spi_info() Lin Yujun
@ 2022-09-26  9:14 ` linyujun (C)
  0 siblings, 0 replies; 2+ messages in thread
From: linyujun (C) @ 2022-09-26  9:14 UTC (permalink / raw)
  To: daniel, haojian.zhuang, robert.jarzmik, linux, lg, eric.miao
  Cc: linux-arm-kernel, linux-kernel

kindly ping

在 2022/9/14 11:33, Lin Yujun 写道:
> In error case in pxa2xx_set_spi_info() after calling
> platform_device_add(), the failed 'pdev' need to be
> release or it will be leak, call platform_device_put()
> to fix this problem.
>
> Fixes: e172274ccc55 ("[ARM] 5088/3: pxa2xx: add pxa2xx_set_spi_info to register pxa2xx-spi platform devices")
> Signed-off-by: Lin Yujun <linyujun809@huawei.com>
> ---
>   arch/arm/mach-pxa/devices.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/mach-pxa/devices.c b/arch/arm/mach-pxa/devices.c
> index a7b92dd1ca9e..2727f0138758 100644
> --- a/arch/arm/mach-pxa/devices.c
> +++ b/arch/arm/mach-pxa/devices.c
> @@ -1087,7 +1087,11 @@ void __init pxa2xx_set_spi_info(unsigned id, struct pxa2xx_spi_controller *info)
>   	}
>   
>   	pd->dev.platform_data = info;
> -	platform_device_add(pd);
> +	if (platform_device_add(pd)) {
> +		printk(KERN_ERR "pxa2xx-spi: failed to add platform device %d\n",
> +			id);
> +		platform_device_put(pd);
> +	}
>   }
>   
>   static struct resource pxa_dma_resource[] = {

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-26  9:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-14  3:33 [PATCH -next] ARM pxa2xx: Add missing platform_device_put() in pxa2xx_set_spi_info() Lin Yujun
2022-09-26  9:14 ` linyujun (C)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®