From: Krzysztof Adamski <krzysztof.adamski-++hxYGjEMp0AvxtiuMwx3w@public.gmane.org>
To: Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Cc: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
"linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Linux Kernel Mailing List
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH] regulator: core: fix error path of regulator_ena_gpio_free
Date: Wed, 24 Feb 2016 09:26:03 +0100 [thread overview]
Message-ID: <20160224082602.GC19954@box2.japko.eu> (raw)
In-Reply-To: <56CC7863.4080202-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
On Tue, Feb 23, 2016 at 03:18:59PM +0000, Jon Hunter wrote:
>
>On 23/02/16 14:47, Krzysztof Adamski wrote:
>> Signed-off-by: Krzysztof Adamski <krzysztof.adamski-++hxYGjEMp0AvxtiuMwx3w@public.gmane.org>
>> Reported-by: Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
>
>Nit ... I think that order of the above should be reversed.
>
Couldn't find any reference stating proper order of those tags and
briefly looking at other commit messages shows this order as quite
common.
>> ---
>> drivers/regulator/core.c | 8 +++-----
>> 1 file changed, 3 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
>> index 6ee9ba4..d1e7859 100644
>> --- a/drivers/regulator/core.c
>> +++ b/drivers/regulator/core.c
>> @@ -3919,7 +3919,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
>> if (ret != 0) {
>> rdev_err(rdev, "Failed to request enable GPIO%d: %d\n",
>> config->ena_gpio, ret);
>> - goto wash;
>> + goto clean;
>> }
>> }
>>
>> @@ -3942,7 +3942,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
>>
>> ret = set_machine_constraints(rdev, constraints);
>> if (ret < 0)
>> - goto scrub;
>> + goto wash;
>>
>> if (init_data && init_data->supply_regulator)
>> rdev->supply_name = init_data->supply_regulator;
>> @@ -3972,10 +3972,8 @@ out:
>> unset_supplies:
>> unset_regulator_supplies(rdev);
>>
>> -scrub:
>> - regulator_ena_gpio_free(rdev);
>> -
>> wash:
>> + regulator_ena_gpio_free(rdev);
>> device_unregister(&rdev->dev);
>> /* device core frees rdev */
>> rdev = ERR_PTR(ret);
>
>What about the case where device_register() fails? I think you still
>call clean and so you will leak the gpio?
>
>Jon
>
True. I couldn't find anything more clever than calling
regulator_ena_gpio_free() in two paths like in an upcomming v2. Putting
it inside of regulator_dev_release() won't entirely fix the problem
either as this won't be called in this particular case
(device_register() fail). I personally still prefer calling
regulator_ena_gpio_free() inside of regulator_register insted of
deffering it to regulator_dev_release() as it seems to be clearer to me.
Best regards,
Krzysztof Adamski
next prev parent reply other threads:[~2016-02-24 8:26 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1456129440-28143-1-git-send-email-krzysztof.adamski@tieto.com>
[not found] ` <1456129440-28143-1-git-send-email-krzysztof.adamski-++hxYGjEMp0AvxtiuMwx3w@public.gmane.org>
2016-02-23 13:22 ` regulator: core: Request GPIO before creating sysfs entries Jon Hunter
[not found] ` <56CC5D1E.6010101-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-02-23 13:56 ` Krzysztof Adamski
2016-02-23 14:15 ` Jon Hunter
2016-02-23 14:34 ` Krzysztof Adamski
2016-02-23 14:47 ` [PATCH] regulator: core: fix error path of regulator_ena_gpio_free Krzysztof Adamski
2016-02-23 15:18 ` Jon Hunter
[not found] ` <56CC7863.4080202-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-02-24 8:26 ` Krzysztof Adamski [this message]
2016-02-24 9:03 ` Jon Hunter
2016-02-24 8:27 ` Krzysztof Adamski
2016-02-24 9:18 ` Jon Hunter
2016-02-24 10:52 ` [PATCH v3] regulator: core: fix crash in error path of regulator_register Krzysztof Adamski
[not found] ` <1456302479-14045-1-git-send-email-krzysztof.adamski-++hxYGjEMp0AvxtiuMwx3w@public.gmane.org>
2016-02-24 9:20 ` [PATCH] regulator: core: fix error path of regulator_ena_gpio_free Jon Hunter
2016-02-25 1:46 ` Mark Brown
2016-02-24 3:48 ` regulator: core: Request GPIO before creating sysfs entries Mark Brown
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=20160224082602.GC19954@box2.japko.eu \
--to=krzysztof.adamski-++hxygjemp0avxtiumwx3w@public.gmane.org \
--cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/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