Skip to content

Commit 151f72f

Browse files
Colin Ian KingpH5
authored andcommitted
reset: fix null pointer dereference on dev by dev_name
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: 2a6cb2b ("reset: Add reset_control_get_count()") Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
1 parent eaf91db commit 151f72f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/reset/core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,12 +799,13 @@ EXPORT_SYMBOL_GPL(devm_reset_control_array_get);
799799
static int reset_control_get_count_from_lookup(struct device *dev)
800800
{
801801
const struct reset_control_lookup *lookup;
802-
const char *dev_id = dev_name(dev);
802+
const char *dev_id;
803803
int count = 0;
804804

805805
if (!dev)
806806
return -EINVAL;
807807

808+
dev_id = dev_name(dev);
808809
mutex_lock(&reset_lookup_mutex);
809810

810811
list_for_each_entry(lookup, &reset_lookup_list, list) {

0 commit comments

Comments
 (0)