* [PATCH] nvmem: core: return -ENOENT if nvmem cell is not found
@ 2023-01-05 13:59 Michael Walle
2023-01-05 14:20 ` Alexander Stein
2023-01-05 17:15 ` Srinivas Kandagatla
0 siblings, 2 replies; 4+ messages in thread
From: Michael Walle @ 2023-01-05 13:59 UTC (permalink / raw)
To: Srinivas Kandagatla, Alexander Stein
Cc: Michael Walle, linux-kernel, Miquel Raynal
Prior to commit 3cb05fdbaed6 ("nvmem: core: add an index parameter to
the cell") of_nvmem_cell_get() would return -ENOENT if the cell wasn't
found. Particularly, if of_property_match_string() returned -EINVAL,
that return code was passed as the index to of_parse_phandle(), which
then detected it as invalid and returned NULL. That led to an return
code of -ENOENT.
With the new code, the negative index will lead to an -EINVAL of
of_parse_phandle_with_optional_args() which pass straight to the
caller and break those who expect an -ENOENT.
Fix it by always returning -ENOENT.
Fixes: 3cb05fdbaed6 ("nvmem: core: add an index parameter to the cell")
Reported-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Michael Walle <michael@walle.cc>
---
Alexander, could you give this another try? I've changed it slightly,
so it's a better match with how the handling was before.
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 1b61c8bf0de4..cc885b602690 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -1343,7 +1343,7 @@ struct nvmem_cell *of_nvmem_cell_get(struct device_node *np, const char *id)
"#nvmem-cell-cells",
index, &cell_spec);
if (ret)
- return ERR_PTR(ret);
+ return ERR_PTR(-ENOENT);
if (cell_spec.args_count > 1)
return ERR_PTR(-EINVAL);
--
2.30.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] nvmem: core: return -ENOENT if nvmem cell is not found
2023-01-05 13:59 [PATCH] nvmem: core: return -ENOENT if nvmem cell is not found Michael Walle
@ 2023-01-05 14:20 ` Alexander Stein
2023-01-05 17:15 ` Srinivas Kandagatla
1 sibling, 0 replies; 4+ messages in thread
From: Alexander Stein @ 2023-01-05 14:20 UTC (permalink / raw)
To: Srinivas Kandagatla, Michael Walle
Cc: Michael Walle, linux-kernel, Miquel Raynal
Am Donnerstag, 5. Januar 2023, 14:59:31 CET schrieb Michael Walle:
> Prior to commit 3cb05fdbaed6 ("nvmem: core: add an index parameter to
> the cell") of_nvmem_cell_get() would return -ENOENT if the cell wasn't
> found. Particularly, if of_property_match_string() returned -EINVAL,
> that return code was passed as the index to of_parse_phandle(), which
> then detected it as invalid and returned NULL. That led to an return
> code of -ENOENT.
>
> With the new code, the negative index will lead to an -EINVAL of
> of_parse_phandle_with_optional_args() which pass straight to the
> caller and break those who expect an -ENOENT.
>
> Fix it by always returning -ENOENT.
>
> Fixes: 3cb05fdbaed6 ("nvmem: core: add an index parameter to the cell")
> Reported-by: Alexander Stein <alexander.stein@ew.tq-group.com>
> Signed-off-by: Michael Walle <michael@walle.cc>
> ---
>
> Alexander, could you give this another try? I've changed it slightly,
> so it's a better match with how the handling was before.
>
>
> 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 1b61c8bf0de4..cc885b602690 100644
> --- a/drivers/nvmem/core.c
> +++ b/drivers/nvmem/core.c
> @@ -1343,7 +1343,7 @@ struct nvmem_cell *of_nvmem_cell_get(struct
> device_node *np, const char *id) "#nvmem-cell-cells",
> index,
&cell_spec);
> if (ret)
> - return ERR_PTR(ret);
> + return ERR_PTR(-ENOENT);
>
> if (cell_spec.args_count > 1)
> return ERR_PTR(-EINVAL);
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] nvmem: core: return -ENOENT if nvmem cell is not found
2023-01-05 13:59 [PATCH] nvmem: core: return -ENOENT if nvmem cell is not found Michael Walle
2023-01-05 14:20 ` Alexander Stein
@ 2023-01-05 17:15 ` Srinivas Kandagatla
1 sibling, 0 replies; 4+ messages in thread
From: Srinivas Kandagatla @ 2023-01-05 17:15 UTC (permalink / raw)
To: Michael Walle, Alexander Stein; +Cc: linux-kernel, Miquel Raynal
On 05/01/2023 13:59, Michael Walle wrote:
> Prior to commit 3cb05fdbaed6 ("nvmem: core: add an index parameter to
> the cell") of_nvmem_cell_get() would return -ENOENT if the cell wasn't
> found. Particularly, if of_property_match_string() returned -EINVAL,
> that return code was passed as the index to of_parse_phandle(), which
> then detected it as invalid and returned NULL. That led to an return
> code of -ENOENT.
>
> With the new code, the negative index will lead to an -EINVAL of
> of_parse_phandle_with_optional_args() which pass straight to the
> caller and break those who expect an -ENOENT.
>
> Fix it by always returning -ENOENT.
>
> Fixes: 3cb05fdbaed6 ("nvmem: core: add an index parameter to the cell")
> Reported-by: Alexander Stein <alexander.stein@ew.tq-group.com>
> Signed-off-by: Michael Walle <michael@walle.cc>
> ---
>
Applied thanks,
--srini
> Alexander, could you give this another try? I've changed it slightly,
> so it's a better match with how the handling was before.
>
>
> 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 1b61c8bf0de4..cc885b602690 100644
> --- a/drivers/nvmem/core.c
> +++ b/drivers/nvmem/core.c
> @@ -1343,7 +1343,7 @@ struct nvmem_cell *of_nvmem_cell_get(struct device_node *np, const char *id)
> "#nvmem-cell-cells",
> index, &cell_spec);
> if (ret)
> - return ERR_PTR(ret);
> + return ERR_PTR(-ENOENT);
>
> if (cell_spec.args_count > 1)
> return ERR_PTR(-EINVAL);
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] nvmem: core: return -ENOENT if nvmem cell is not found
@ 2023-03-10 9:48 Srinivas Kandagatla
0 siblings, 0 replies; 4+ messages in thread
From: Srinivas Kandagatla @ 2023-03-10 9:48 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, Michael Walle, Alexander Stein, Srinivas Kandagatla
From: Michael Walle <michael@walle.cc>
Prior to commit 5d8e6e6c10a3 ("nvmem: core: add an index parameter to
the cell") of_nvmem_cell_get() would return -ENOENT if the cell wasn't
found. Particularly, if of_property_match_string() returned -EINVAL,
that return code was passed as the index to of_parse_phandle(), which
then detected it as invalid and returned NULL. That led to an return
code of -ENOENT.
With the new code, the negative index will lead to an -EINVAL of
of_parse_phandle_with_optional_args() which pass straight to the
caller and break those who expect an -ENOENT.
Fix it by always returning -ENOENT.
Fixes: 5d8e6e6c10a3 ("nvmem: core: add an index parameter to the cell")
Reported-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Link: https://lore.kernel.org/r/2143916.GUh0CODmnK@steina-w/
Signed-off-by: Michael Walle <michael@walle.cc>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
Hi Greg,
Could you please pick this nvmem fix for next possible rc.
thanks for your help.
--Srini
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 174ef3574e07..22024b830788 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -1231,7 +1231,7 @@ struct nvmem_cell *of_nvmem_cell_get(struct device_node *np, const char *id)
"#nvmem-cell-cells",
index, &cell_spec);
if (ret)
- return ERR_PTR(ret);
+ return ERR_PTR(-ENOENT);
if (cell_spec.args_count > 1)
return ERR_PTR(-EINVAL);
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-03-10 9:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-05 13:59 [PATCH] nvmem: core: return -ENOENT if nvmem cell is not found Michael Walle
2023-01-05 14:20 ` Alexander Stein
2023-01-05 17:15 ` Srinivas Kandagatla
2023-03-10 9:48 Srinivas Kandagatla
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).