* [PATCH] hwmon: (ibmaem) don't call platform_device_del() if platform_device_add() fails
@ 2022-07-01 7:41 Yang Yingliang
2022-07-01 18:53 ` Guenter Roeck
0 siblings, 1 reply; 2+ messages in thread
From: Yang Yingliang @ 2022-07-01 7:41 UTC (permalink / raw)
To: linux-kernel, linux-hwmon; +Cc: linux, jdelvare
If platform_device_add() fails, it no need to call platform_device_del(), split
platform_device_unregister() into platform_device_del/put(), so platform_device_put()
can be called separately.
Fixes: 8808a793f052 ("ibmaem: new driver for power/energy/temp meters in IBM System X hardware")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
drivers/hwmon/ibmaem.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
index 5c4cf742f5ae..157e232aace0 100644
--- a/drivers/hwmon/ibmaem.c
+++ b/drivers/hwmon/ibmaem.c
@@ -550,7 +550,7 @@ static int aem_init_aem1_inst(struct aem_ipmi_data *probe, u8 module_handle)
res = platform_device_add(data->pdev);
if (res)
- goto ipmi_err;
+ goto dev_add_err;
platform_set_drvdata(data->pdev, data);
@@ -598,7 +598,9 @@ static int aem_init_aem1_inst(struct aem_ipmi_data *probe, u8 module_handle)
ipmi_destroy_user(data->ipmi.user);
ipmi_err:
platform_set_drvdata(data->pdev, NULL);
- platform_device_unregister(data->pdev);
+ platform_device_del(data->pdev);
+dev_add_err:
+ platform_device_put(data->pdev);
dev_err:
ida_free(&aem_ida, data->id);
id_err:
@@ -690,7 +692,7 @@ static int aem_init_aem2_inst(struct aem_ipmi_data *probe,
res = platform_device_add(data->pdev);
if (res)
- goto ipmi_err;
+ goto dev_add_err;
platform_set_drvdata(data->pdev, data);
@@ -738,7 +740,9 @@ static int aem_init_aem2_inst(struct aem_ipmi_data *probe,
ipmi_destroy_user(data->ipmi.user);
ipmi_err:
platform_set_drvdata(data->pdev, NULL);
- platform_device_unregister(data->pdev);
+ platform_device_del(data->pdev);
+dev_add_err:
+ platform_device_put(data->pdev);
dev_err:
ida_free(&aem_ida, data->id);
id_err:
--
2.25.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] hwmon: (ibmaem) don't call platform_device_del() if platform_device_add() fails
2022-07-01 7:41 [PATCH] hwmon: (ibmaem) don't call platform_device_del() if platform_device_add() fails Yang Yingliang
@ 2022-07-01 18:53 ` Guenter Roeck
0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2022-07-01 18:53 UTC (permalink / raw)
To: Yang Yingliang; +Cc: linux-kernel, linux-hwmon, jdelvare
On Fri, Jul 01, 2022 at 03:41:53PM +0800, Yang Yingliang wrote:
> If platform_device_add() fails, it no need to call platform_device_del(), split
> platform_device_unregister() into platform_device_del/put(), so platform_device_put()
> can be called separately.
>
> Fixes: 8808a793f052 ("ibmaem: new driver for power/energy/temp meters in IBM System X hardware")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Applied.
Thanks,
Guenter
> ---
> drivers/hwmon/ibmaem.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
> index 5c4cf742f5ae..157e232aace0 100644
> --- a/drivers/hwmon/ibmaem.c
> +++ b/drivers/hwmon/ibmaem.c
> @@ -550,7 +550,7 @@ static int aem_init_aem1_inst(struct aem_ipmi_data *probe, u8 module_handle)
>
> res = platform_device_add(data->pdev);
> if (res)
> - goto ipmi_err;
> + goto dev_add_err;
>
> platform_set_drvdata(data->pdev, data);
>
> @@ -598,7 +598,9 @@ static int aem_init_aem1_inst(struct aem_ipmi_data *probe, u8 module_handle)
> ipmi_destroy_user(data->ipmi.user);
> ipmi_err:
> platform_set_drvdata(data->pdev, NULL);
> - platform_device_unregister(data->pdev);
> + platform_device_del(data->pdev);
> +dev_add_err:
> + platform_device_put(data->pdev);
> dev_err:
> ida_free(&aem_ida, data->id);
> id_err:
> @@ -690,7 +692,7 @@ static int aem_init_aem2_inst(struct aem_ipmi_data *probe,
>
> res = platform_device_add(data->pdev);
> if (res)
> - goto ipmi_err;
> + goto dev_add_err;
>
> platform_set_drvdata(data->pdev, data);
>
> @@ -738,7 +740,9 @@ static int aem_init_aem2_inst(struct aem_ipmi_data *probe,
> ipmi_destroy_user(data->ipmi.user);
> ipmi_err:
> platform_set_drvdata(data->pdev, NULL);
> - platform_device_unregister(data->pdev);
> + platform_device_del(data->pdev);
> +dev_add_err:
> + platform_device_put(data->pdev);
> dev_err:
> ida_free(&aem_ida, data->id);
> id_err:
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-07-01 18:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-01 7:41 [PATCH] hwmon: (ibmaem) don't call platform_device_del() if platform_device_add() fails Yang Yingliang
2022-07-01 18:53 ` Guenter Roeck
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®