archive mirror
 help / color / mirror / Atom feed
From: Colin King <>
To: Philipp Zabel <>
Subject: [PATCH][next] reset: fix null pointer dereference on dev by dev_name
Date: Wed, 14 Nov 2018 21:49:35 +0000	[thread overview]
Message-ID: <> (raw)

From: Colin Ian King <>

The call to dev_name will dereference dev, however, dev is later
being null checked, so there is a possibility of a null pointer
dereference on dev by the call to dev_name. Fix this by null
checking dev first before the call to dev_name

Detected by CoverityScan, CID#1475475 ("Dereference before null check")

Fixes: 2a6cb2b1d83b ("reset: Add reset_control_get_count()")
Signed-off-by: Colin Ian King <>
 drivers/reset/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/reset/core.c b/drivers/reset/core.c
index 7f95fcb7805d..3d9a887c217e 100644
--- a/drivers/reset/core.c
+++ b/drivers/reset/core.c
@@ -799,12 +799,13 @@ EXPORT_SYMBOL_GPL(devm_reset_control_array_get);
 static int reset_control_get_count_from_lookup(struct device *dev)
 	const struct reset_control_lookup *lookup;
-	const char *dev_id = dev_name(dev);
+	const char *dev_id;
 	int count = 0;
 	if (!dev)
 		return -EINVAL;
+	dev_id = dev_name(dev);
 	list_for_each_entry(lookup, &reset_lookup_list, list) {

             reply	other threads:[~2018-11-14 21:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-14 21:49 Colin King [this message]
2018-11-15  9:33 ` Philipp Zabel

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \
    --subject='Re: [PATCH][next] reset: fix null pointer dereference on dev by dev_name' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).