public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] nvmem: core: fix return value
Date: Tue, 10 Jan 2023 16:54:27 +0000	[thread overview]
Message-ID: <Y72YQ+gQ3+TsGLz/@shell.armlinux.org.uk> (raw)
In-Reply-To: <d70e0b2f-4e13-a137-eaf7-b2c298926d85@linaro.org>

On Tue, Jan 10, 2023 at 04:50:05PM +0000, Srinivas Kandagatla wrote:
> Hi Russell,
> 
> On 10/01/2023 16:48, Russell King (Oracle) wrote:
> > Dan Carpenter points out that the return code was not set in commit
> > 60c8b4aebd8e ("nvmem: core: fix cleanup after dev_set_name()"), but
> > this is not the only issue - we also need to zero wp_gpio to prevent
> > gpiod_put() being called on an error value.
> > 
> > Reported-by: kernel test robot <lkp@intel.com>
> > Reported-by: Dan Carpenter <error27@gmail.com>
> > Fixes: 60c8b4aebd8e ("nvmem: core: fix cleanup after dev_set_name()")
> > Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> > ---
> >   drivers/nvmem/core.c | 5 ++++-
> >   1 file changed, 4 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> > index 082cda7ac199..1ee2e9255f7b 100644
> > --- a/drivers/nvmem/core.c
> > +++ b/drivers/nvmem/core.c
> > @@ -781,8 +781,11 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
> >   	if (!config->ignore_wp)
> >   		nvmem->wp_gpio = gpiod_get_optional(config->dev, "wp",
> >   						    GPIOD_OUT_HIGH);
> > -	if (IS_ERR(nvmem->wp_gpio))
> > +	if (IS_ERR(nvmem->wp_gpio)) {
> > +		rval = PTR_ERR(nvmem->wp_gpio);
> > +		nvmem->wp_gpio = NULL;
> >   		goto err_put_device;
> 
> I have already added this change while applying v3 patches.

You still need wp_gpio to be NULL'd out, otherwise we'll end up calling
gpiod_put() on the error-pointer.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2023-01-10 16:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-10 16:48 [PATCH] nvmem: core: fix return value Russell King (Oracle)
2023-01-10 16:50 ` Srinivas Kandagatla
2023-01-10 16:54   ` Russell King (Oracle) [this message]
2023-01-10 17:05     ` Srinivas Kandagatla

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=Y72YQ+gQ3+TsGLz/@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=srinivas.kandagatla@linaro.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