public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexander Stein <alexander.stein@ew.tq-group.com>
To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
	Michael Walle <michael@walle.cc>
Cc: Michael Walle <michael@walle.cc>,
	linux-kernel@vger.kernel.org,
	Miquel Raynal <miquel.raynal@bootlin.com>
Subject: Re: [PATCH] nvmem: core: return -ENOENT if nvmem cell is not found
Date: Thu, 05 Jan 2023 15:20:53 +0100	[thread overview]
Message-ID: <1888904.g5d078U9FE@steina-w> (raw)
In-Reply-To: <20230105135931.2743351-1-michael@walle.cc>

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>




  reply	other threads:[~2023-01-05 14:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2023-01-05 17:15 ` Srinivas Kandagatla
  -- strict thread matches above, loose matches on Subject: below --
2023-03-10  9:48 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=1888904.g5d078U9FE@steina-w \
    --to=alexander.stein@ew.tq-group.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael@walle.cc \
    --cc=miquel.raynal@bootlin.com \
    --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