* [PATCH] nvmem: core: fix return value
@ 2023-01-10 16:48 Russell King (Oracle)
2023-01-10 16:50 ` Srinivas Kandagatla
0 siblings, 1 reply; 4+ messages in thread
From: Russell King (Oracle) @ 2023-01-10 16:48 UTC (permalink / raw)
To: Srinivas Kandagatla; +Cc: linux-arm-kernel
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;
+ }
kref_init(&nvmem->refcnt);
INIT_LIST_HEAD(&nvmem->cells);
--
2.30.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] nvmem: core: fix return value
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)
0 siblings, 1 reply; 4+ messages in thread
From: Srinivas Kandagatla @ 2023-01-10 16:50 UTC (permalink / raw)
To: Russell King (Oracle); +Cc: linux-arm-kernel
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.
thanks,
--srini
> + }
>
> kref_init(&nvmem->refcnt);
> INIT_LIST_HEAD(&nvmem->cells);
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] nvmem: core: fix return value
2023-01-10 16:50 ` Srinivas Kandagatla
@ 2023-01-10 16:54 ` Russell King (Oracle)
2023-01-10 17:05 ` Srinivas Kandagatla
0 siblings, 1 reply; 4+ messages in thread
From: Russell King (Oracle) @ 2023-01-10 16:54 UTC (permalink / raw)
To: Srinivas Kandagatla; +Cc: linux-arm-kernel
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] nvmem: core: fix return value
2023-01-10 16:54 ` Russell King (Oracle)
@ 2023-01-10 17:05 ` Srinivas Kandagatla
0 siblings, 0 replies; 4+ messages in thread
From: Srinivas Kandagatla @ 2023-01-10 17:05 UTC (permalink / raw)
To: Russell King (Oracle); +Cc: linux-arm-kernel
On 10/01/2023 16:54, Russell King (Oracle) wrote:
> 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.
That is true..
applied
thanks,
--srini
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-01-10 17:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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)
2023-01-10 17:05 ` Srinivas Kandagatla
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.