From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Hector Martin <marcan@marcan.st>
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
Sven Peter <sven@svenpeter.dev>,
Alyssa Rosenzweig <alyssa@rosenzweig.io>,
asahi@lists.linux.dev, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, Eric Curtin <ecurtin@redhat.com>
Subject: Re: [PATCH v2] nvmem: core: Fix race in nvmem_register()
Date: Tue, 3 Jan 2023 15:22:25 +0000 [thread overview]
Message-ID: <Y7RIMeMoKD70NIcc@shell.armlinux.org.uk> (raw)
In-Reply-To: <ec2c2712-04fa-751d-9817-23ff4e0b7fb4@marcan.st>
On Wed, Jan 04, 2023 at 12:14:10AM +0900, Hector Martin wrote:
> On 04/01/2023 00.06, Russell King (Oracle) wrote:
> > Hi Hector,
> >
> > On Tue, Jan 03, 2023 at 10:48:52PM +0900, Hector Martin wrote:
> >>>> @@ -822,11 +822,8 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
> >>>> break;
> >>>> }
> >>>>
> >>>> - if (rval) {
> >>>> - ida_free(&nvmem_ida, nvmem->id);
> >>>> - kfree(nvmem);
> >>>> - return ERR_PTR(rval);
> >>>> - }
> >>>> + if (rval)
> >>>> + goto err_gpiod_put;
> >>>
> >>> Why was gpiod changes added to this patch, that should be a separate
> >>> patch/discussion, as this is not relevant to the issue that you are
> >>> reporting.
> >>
> >> Because freeing the device also does a gpiod_put in the destructor, so
> >> doing this is correct in every other instance below and maintains
> >> existing behavior, and it just so happens that this instance converges
> >> into the same codepath so it is correct to merge it, and it just so
> >> happens that the gpiod put was missing in this path to begin with so
> >> this becomes a drive-by bugfix.
> >>
> >> If you don't like it I can remove it (i.e. reintroduce the bug for no
> >> good reason) and you can submit this fix yourself, because I have no
> >> incentive to waste time submitting a separate patch to fix a GPIO leak
> >> in an error path corner case in a subsystem I don't own and I have much
> >> bigger things to spend my (increasingly lower and lower) willingness to
> >> fight for upstream submissions than this.
> >>
> >> Seriously, what is wrong with y'all kernel people. No other open source
> >> project wastes contributors' time with stupid nitpicks like this. I
> >> found a bug, I fixed it, I then fixed the issues you pointed out, and I
> >> don't have the time nor energy to fight over this kind of nonsense next.
> >> Do you want bugs fixed or not?
> >
> > This is not nonsense. We have always had a policy of one fix/change
> > per patch, and in this case it makes complete and utter sense. Of
> > course, the interpretation of "one change" is a matter of opinion.
>
> The change here is the race condition fix. That change involves adding
> an error cleanup path that involves a gpio_put(). Therefore it seems
> logical to actually use it in that one extra case that should've used it
> anyway, a few lines above.
The two are entirely unrelated. as I've already explained. The call
to device_register() happens _after_ the check for rval from the
dev_set_name() that you are changing. Moving device_register() doesn't
make the lack of gpiod_put() any better or worse than it was before.
That said, I'm now thinking that my patch is actually wrong, but for
a different reason unrelated to the gpiod issue. :(
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
prev parent reply other threads:[~2023-01-03 15:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-03 11:44 [PATCH v2] nvmem: core: Fix race in nvmem_register() Hector Martin
2023-01-03 12:41 ` Srinivas Kandagatla
2023-01-03 13:48 ` Hector Martin
2023-01-03 14:22 ` Srinivas Kandagatla
2023-01-03 14:56 ` Hector Martin
2023-01-03 15:18 ` Russell King (Oracle)
2023-01-03 15:33 ` Hector Martin
2023-01-03 16:03 ` Russell King (Oracle)
2023-01-03 15:06 ` Russell King (Oracle)
2023-01-03 15:14 ` Hector Martin
2023-01-03 15:22 ` Russell King (Oracle) [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=Y7RIMeMoKD70NIcc@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=alyssa@rosenzweig.io \
--cc=asahi@lists.linux.dev \
--cc=ecurtin@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=marcan@marcan.st \
--cc=srinivas.kandagatla@linaro.org \
--cc=stable@vger.kernel.org \
--cc=sven@svenpeter.dev \
/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