[PATCH -next] [ARM] am300epd: Release platform device in case of platform_device_add_data() fails

linyujun (C) linyujun809 at huawei.com
Mon Sep 26 02:15:22 PDT 2022


kindly ping

在 2022/9/14 11:34, Lin Yujun 写道:
> 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;



More information about the linux-arm-kernel mailing list