From: Guenter Roeck <linux@roeck-us.net>
To: Yang Yingliang <yangyingliang@huawei.com>
Cc: linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org,
jdelvare@suse.com
Subject: Re: [PATCH] hwmon: (ibmaem) don't call platform_device_del() if platform_device_add() fails
Date: Fri, 1 Jul 2022 11:53:43 -0700 [thread overview]
Message-ID: <20220701185343.GA2981066@roeck-us.net> (raw)
In-Reply-To: <20220701074153.4021556-1-yangyingliang@huawei.com>
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:
prev parent reply other threads:[~2022-07-01 18:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-01 7:41 Yang Yingliang
2022-07-01 18:53 ` Guenter Roeck [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220701185343.GA2981066@roeck-us.net \
--to=linux@roeck-us.net \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=yangyingliang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®