diff options
author | Colin Ian King <colin.king@canonical.com> | 2018-11-15 00:49:35 +0300 |
---|---|---|
committer | Philipp Zabel <p.zabel@pengutronix.de> | 2019-01-07 18:38:26 +0300 |
commit | 151f72f493f2605ebbed0198362eed05918ed839 (patch) | |
tree | 2816e7b09fc0d3517a41ce05a9d15e0472e36995 /drivers/reset | |
parent | eaf91db0ab22dc2c664a9782f2f31dcbc410f3b5 (diff) | |
download | linux-151f72f493f2605ebbed0198362eed05918ed839.tar.xz |
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: 2a6cb2b1d83b ("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>
Diffstat (limited to 'drivers/reset')
-rw-r--r-- | drivers/reset/core.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/reset/core.c b/drivers/reset/core.c index bce2d6aefef9..9582efb70025 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); mutex_lock(&reset_lookup_mutex); list_for_each_entry(lookup, &reset_lookup_list, list) { |