linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] reset: fix potential null pointer dereference on pointer dev
@ 2019-05-09 16:00 Colin King
  2019-05-10  9:14 ` Philipp Zabel
  0 siblings, 1 reply; 3+ messages in thread
From: Colin King @ 2019-05-09 16:00 UTC (permalink / raw)
  To: Philipp Zabel; +Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Pointer dev is being dereferenced when passed to the inlined
functon dev_name, however, dev is later being null checked.
Thus there is a potential null pointer dereference on a null
dev. Fix this by performing the null check on dev before
dereferencing it.

Addresses-Coverity: ("Dereference before null check")
Fixes: 6691dffab0ab ("reset: add support for non-DT systems")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 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 81ea77cba123..83f1a1d5ee67 100644
--- a/drivers/reset/core.c
+++ b/drivers/reset/core.c
@@ -691,12 +691,13 @@ __reset_control_get_from_lookup(struct device *dev, const char *con_id,
 {
 	const struct reset_control_lookup *lookup;
 	struct reset_controller_dev *rcdev;
-	const char *dev_id = dev_name(dev);
+	const char *dev_id;
 	struct reset_control *rstc = NULL;
 
 	if (!dev)
 		return ERR_PTR(-EINVAL);
 
+	dev_id = dev_name(dev);
 	mutex_lock(&reset_lookup_mutex);
 
 	list_for_each_entry(lookup, &reset_lookup_list, list) {
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-05-10  9:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-09 16:00 [PATCH] reset: fix potential null pointer dereference on pointer dev Colin King
2019-05-10  9:14 ` Philipp Zabel
2019-05-10  9:16   ` Colin Ian King

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