reset: remove redundant null check on pointer dev
authorColin Ian King <colin.king@canonical.com>
Fri, 10 May 2019 09:58:32 +0000 (10:58 +0100)
committerPhilipp Zabel <p.zabel@pengutronix.de>
Thu, 4 Jul 2019 10:10:55 +0000 (12:10 +0200)
Pointer dev is being dereferenced when passed to the inlined
functon dev_name, however, dev is later being null checked
so at first this seems like a potential null pointer dereference.

In fact, _reset_control_get_from_lookup is only ever called from
__reset_control_get, right after checking dev->of_node hence
dev can never be null.  Clean this up by removing the redundant
null check.

Thanks to Philipp Zabel for spotting that dev can never be null.

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>
Reviewed-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
drivers/reset/core.c

index 81ea77cba123bce54749d69fa727e9027eed450f..921f4bbbad8a6b872d03af3f1a22257b557ccc79 100644 (file)
@@ -694,9 +694,6 @@ __reset_control_get_from_lookup(struct device *dev, const char *con_id,
        const char *dev_id = dev_name(dev);
        struct reset_control *rstc = NULL;
 
-       if (!dev)
-               return ERR_PTR(-EINVAL);
-
        mutex_lock(&reset_lookup_mutex);
 
        list_for_each_entry(lookup, &reset_lookup_list, list) {