* [PATCH] nvmem: core: fix the return value check when calling the notifier chain
@ 2019-02-14 16:23 Bartosz Golaszewski
2019-02-15 9:28 ` Srinivas Kandagatla
0 siblings, 1 reply; 5+ messages in thread
From: Bartosz Golaszewski @ 2019-02-14 16:23 UTC (permalink / raw)
To: Srinivas Kandagatla, Greg Kroah-Hartman
Cc: linux-kernel, Bartosz Golaszewski, stable
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
blocking_notifier_call_chain() returns the value returned by the last
registered callback. A positive return value doesn't indicate an error
so check only if it's negative.
Fixes: bee1138bea15 ("nvmem: add a notifier chain")
Cc: stable@vger.kernel.org
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
drivers/nvmem/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index f7301bb4ef3b..a3bed2d9aec7 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -687,7 +687,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
goto err_remove_cells;
rval = blocking_notifier_call_chain(&nvmem_notifier, NVMEM_ADD, nvmem);
- if (rval)
+ if (rval < 0)
goto err_remove_cells;
return nvmem;
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] nvmem: core: fix the return value check when calling the notifier chain
2019-02-14 16:23 [PATCH] nvmem: core: fix the return value check when calling the notifier chain Bartosz Golaszewski
@ 2019-02-15 9:28 ` Srinivas Kandagatla
2019-02-15 9:41 ` Bartosz Golaszewski
0 siblings, 1 reply; 5+ messages in thread
From: Srinivas Kandagatla @ 2019-02-15 9:28 UTC (permalink / raw)
To: Bartosz Golaszewski, Greg Kroah-Hartman
Cc: linux-kernel, Bartosz Golaszewski, stable
On 14/02/2019 16:23, Bartosz Golaszewski wrote:
> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> index f7301bb4ef3b..a3bed2d9aec7 100644
> --- a/drivers/nvmem/core.c
> +++ b/drivers/nvmem/core.c
> @@ -687,7 +687,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
> goto err_remove_cells;
>
> rval = blocking_notifier_call_chain(&nvmem_notifier, NVMEM_ADD, nvmem);
> - if (rval)
> + if (rval < 0)
> goto err_remove_cells;
rval will be masked with STOP MASK, so the above statement could be
false even if we have error.
So you should consider returning an errono which can be understood by user:
may be something like this:
if (rval & NOTIFY_STOP_MASK) {
rval = notifier_to_errno(rval);
goto err_remove_cells
}
--srini
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] nvmem: core: fix the return value check when calling the notifier chain
2019-02-15 9:28 ` Srinivas Kandagatla
@ 2019-02-15 9:41 ` Bartosz Golaszewski
2019-02-15 10:26 ` Srinivas Kandagatla
0 siblings, 1 reply; 5+ messages in thread
From: Bartosz Golaszewski @ 2019-02-15 9:41 UTC (permalink / raw)
To: Srinivas Kandagatla
Cc: Greg Kroah-Hartman, Linux Kernel Mailing List,
Bartosz Golaszewski, stable
pt., 15 lut 2019 o 10:28 Srinivas Kandagatla
<srinivas.kandagatla@linaro.org> napisał(a):
>
>
>
> On 14/02/2019 16:23, Bartosz Golaszewski wrote:
> > diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> > index f7301bb4ef3b..a3bed2d9aec7 100644
> > --- a/drivers/nvmem/core.c
> > +++ b/drivers/nvmem/core.c
> > @@ -687,7 +687,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
> > goto err_remove_cells;
> >
> > rval = blocking_notifier_call_chain(&nvmem_notifier, NVMEM_ADD, nvmem);
> > - if (rval)
> > + if (rval < 0)
> > goto err_remove_cells;
>
> rval will be masked with STOP MASK, so the above statement could be
> false even if we have error.
> So you should consider returning an errono which can be understood by user:
>
> may be something like this:
>
> if (rval & NOTIFY_STOP_MASK) {
> rval = notifier_to_errno(rval);
> goto err_remove_cells
> }
>
Actually I'm now thinking we can remove this check at all - most users
never check the return values of notifier chain calls. This function
cannot fail in itself. What do you think?
Bart
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] nvmem: core: fix the return value check when calling the notifier chain
2019-02-15 9:41 ` Bartosz Golaszewski
@ 2019-02-15 10:26 ` Srinivas Kandagatla
2019-02-15 10:43 ` Bartosz Golaszewski
0 siblings, 1 reply; 5+ messages in thread
From: Srinivas Kandagatla @ 2019-02-15 10:26 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Greg Kroah-Hartman, Linux Kernel Mailing List,
Bartosz Golaszewski, stable
On 15/02/2019 09:41, Bartosz Golaszewski wrote:
>> rval will be masked with STOP MASK, so the above statement could be
>> false even if we have error.
>> So you should consider returning an errono which can be understood by user:
>>
>> may be something like this:
>>
>> if (rval & NOTIFY_STOP_MASK) {
>> rval = notifier_to_errno(rval);
>> goto err_remove_cells
>> }
>>
> Actually I'm now thinking we can remove this check at all - most users
> never check the return values of notifier chain calls. This function
> cannot fail in itself. What do you think?
Thats even better, I was about to suggest the same on the fact that we
should allow nvmem provider to register to be successful irrespective of
the notifier callback failures.
--srini
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] nvmem: core: fix the return value check when calling the notifier chain
2019-02-15 10:26 ` Srinivas Kandagatla
@ 2019-02-15 10:43 ` Bartosz Golaszewski
0 siblings, 0 replies; 5+ messages in thread
From: Bartosz Golaszewski @ 2019-02-15 10:43 UTC (permalink / raw)
To: Srinivas Kandagatla
Cc: Greg Kroah-Hartman, Linux Kernel Mailing List,
Bartosz Golaszewski, stable
pt., 15 lut 2019 o 11:26 Srinivas Kandagatla
<srinivas.kandagatla@linaro.org> napisał(a):
>
>
>
> On 15/02/2019 09:41, Bartosz Golaszewski wrote:
> >> rval will be masked with STOP MASK, so the above statement could be
> >> false even if we have error.
> >> So you should consider returning an errono which can be understood by user:
> >>
> >> may be something like this:
> >>
> >> if (rval & NOTIFY_STOP_MASK) {
> >> rval = notifier_to_errno(rval);
> >> goto err_remove_cells
> >> }
> >>
> > Actually I'm now thinking we can remove this check at all - most users
> > never check the return values of notifier chain calls. This function
> > cannot fail in itself. What do you think?
> Thats even better, I was about to suggest the same on the fact that we
> should allow nvmem provider to register to be successful irrespective of
> the notifier callback failures.
>
> --srini
Right, I sent a different patch.
Bart
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-02-15 10:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-14 16:23 [PATCH] nvmem: core: fix the return value check when calling the notifier chain Bartosz Golaszewski
2019-02-15 9:28 ` Srinivas Kandagatla
2019-02-15 9:41 ` Bartosz Golaszewski
2019-02-15 10:26 ` Srinivas Kandagatla
2019-02-15 10:43 ` Bartosz Golaszewski
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.