From: Colin King <colin.king@canonical.com>
To: 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>,
Philipp Zabel <p.zabel@pengutronix.de>,
openbmc@lists.ozlabs.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH][next] reset: npcm: check for NULL return from syscon_regmap_lookup_by_compat
Date: Fri, 8 Nov 2019 15:55:24 +0000 [thread overview]
Message-ID: <20191108155524.170566-1-colin.king@canonical.com> (raw)
From: Colin Ian King <colin.king@canonical.com>
Function syscon_regmap_lookup_by_compat can return a NULL pointer, so
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 */
--
2.20.1
next reply other threads:[~2019-11-08 15:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-08 15:55 Colin King [this message]
2019-11-14 13:22 ` [PATCH][next] reset: npcm: check for NULL return from syscon_regmap_lookup_by_compat Philipp Zabel
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=20191108155524.170566-1-colin.king@canonical.com \
--to=colin.king@canonical.com \
--cc=avifishman70@gmail.com \
--cc=benjaminfair@google.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=openbmc@lists.ozlabs.org \
--cc=p.zabel@pengutronix.de \
--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).