linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Philipp Zabel <p.zabel@pengutronix.de>
To: Colin King <colin.king@canonical.com>,
	Avi Fishman <avifishman70@gmail.com>,
	Tomer Maimon <tmaimon77@gmail.com>,
	Tali Perry <tali.perry1@gmail.com>,
	Patrick Venture <venture@google.com>,
	Nancy Yuen <yuenn@google.com>,
	Benjamin Fair <benjaminfair@google.com>,
	openbmc@lists.ozlabs.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH][next] reset: npcm: check for NULL return from syscon_regmap_lookup_by_compat
Date: Thu, 14 Nov 2019 14:22:56 +0100	[thread overview]
Message-ID: <ea47e8e7a8663d33acb44dd4473a5a150ea51526.camel@pengutronix.de> (raw)
In-Reply-To: <20191108155524.170566-1-colin.king@canonical.com>

Hi Colin,

On Fri, 2019-11-08 at 15:55 +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Function syscon_regmap_lookup_by_compat can return a NULL pointer, so

Could you point out where that NULL pointer would come from? As far as I
understand, syscon_regmap_lookup_by_compatible() should either return a
negative error code, or syscon->regmap, which should never be NULL.

> the IS_ERR check on the return is incorrect. Fix this by checking for
> IS_ERR_OR_NULL and return -ENODEV if true.  This avoids a null pointer
> dereference on gcr_regmap later on.
> 
> Addresses-Coverity: ("Dereference null return (stat)")
> Fixes: b3f1d036f26d ("reset: npcm: add NPCM reset controller driver")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/reset/reset-npcm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/reset/reset-npcm.c b/drivers/reset/reset-npcm.c
> index 2ea4d3136e15..9febf8bed2f6 100644
> --- a/drivers/reset/reset-npcm.c
> +++ b/drivers/reset/reset-npcm.c
> @@ -161,9 +161,9 @@ static int npcm_usb_reset(struct platform_device *pdev, struct npcm_rc_data *rc)
>  	of_match_device(dev->driver->of_match_table, dev)->data;
>  
>  	gcr_regmap = syscon_regmap_lookup_by_compatible(gcr_dt);
> -	if (IS_ERR(gcr_regmap)) {
> +	if (IS_ERR_OR_NULL(gcr_regmap)) {
>  		dev_err(&pdev->dev, "Failed to find %s\n", gcr_dt);
> -		return PTR_ERR(gcr_regmap);
> +		return -ENODEV;
>  	}
>  
>  	/* checking which USB device is enabled */

regards
Philipp


  reply	other threads:[~2019-11-14 13:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-08 15:55 [PATCH][next] reset: npcm: check for NULL return from syscon_regmap_lookup_by_compat Colin King
2019-11-14 13:22 ` Philipp Zabel [this message]
2019-11-14 13:36   ` Colin Ian King

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=ea47e8e7a8663d33acb44dd4473a5a150ea51526.camel@pengutronix.de \
    --to=p.zabel@pengutronix.de \
    --cc=avifishman70@gmail.com \
    --cc=benjaminfair@google.com \
    --cc=colin.king@canonical.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=openbmc@lists.ozlabs.org \
    --cc=tali.perry1@gmail.com \
    --cc=tmaimon77@gmail.com \
    --cc=venture@google.com \
    --cc=yuenn@google.com \
    /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).