linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
To: Bartosz Golaszewski <brgl@bgdev.pl>,
	Arnd Bergmann <arnd@arndb.de>, Greg KH <greg@kroah.com>,
	Stephen Rothwell <sfr@canb.auug.org.au>
Cc: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>
Subject: Re: [PATCH v3] nvmem: fix nvmem_cell_get_from_lookup()
Date: Wed, 3 Oct 2018 09:28:09 +0100	[thread overview]
Message-ID: <16778679-514a-a3f6-edd5-b92e0e23830a@linaro.org> (raw)
In-Reply-To: <20181003073111.27212-1-brgl@bgdev.pl>



On 03/10/18 08:31, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> 
> We check if the pointer returned by __nvmem_device_get() is not NULL
> while we should actually check if it is not IS_ERR(nvmem). Fix it.
> 
> While we're at it: fix the next error path where we should assign an
> error value to cell before returning.
> 
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>

Acked-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

> ---
> v1 -> v2:
> - use ERR_CAST() instead of a direct pointer cast
> 
> v2 -> v3:
> - added the Reported-by tag
> 
>   drivers/nvmem/core.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> index ad1227df1984..f49474e1ad49 100644
> --- a/drivers/nvmem/core.c
> +++ b/drivers/nvmem/core.c
> @@ -952,9 +952,9 @@ nvmem_cell_get_from_lookup(struct device *dev, const char *con_id)
>   		    (strcmp(lookup->con_id, con_id) == 0)) {
>   			/* This is the right entry. */
>   			nvmem = __nvmem_device_get(NULL, lookup->nvmem_name);
> -			if (!nvmem) {
> +			if (IS_ERR(nvmem)) {
>   				/* Provider may not be registered yet. */
> -				cell = ERR_PTR(-EPROBE_DEFER);
> +				cell = ERR_CAST(nvmem);
>   				goto out;
>   			}
>   
> @@ -962,6 +962,7 @@ nvmem_cell_get_from_lookup(struct device *dev, const char *con_id)
>   						       lookup->cell_name);
>   			if (!cell) {
>   				__nvmem_device_put(nvmem);
> +				cell = ERR_PTR(-ENOENT);
>   				goto out;
>   			}
>   		}
> 

      reply	other threads:[~2018-10-03  8:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-03  7:31 [PATCH v3] nvmem: fix nvmem_cell_get_from_lookup() Bartosz Golaszewski
2018-10-03  8:28 ` Srinivas Kandagatla [this message]

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=16778679-514a-a3f6-edd5-b92e0e23830a@linaro.org \
    --to=srinivas.kandagatla@linaro.org \
    --cc=arnd@arndb.de \
    --cc=bgolaszewski@baylibre.com \
    --cc=brgl@bgdev.pl \
    --cc=greg@kroah.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sfr@canb.auug.org.au \
    /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;
as well as URLs for NNTP newsgroup(s).