From: Wei Yongjun Date: Mon, 10 Sep 2012 04:52:02 +0000 (+0800) Subject: hwspinlock/core: move the dereference below the NULL test X-Git-Tag: firefly_0821_release~3680^2~2071^2 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e352614cd3e7a5f7af7cff894a3b5a705181de21;p=firefly-linux-kernel-4.4.55.git hwspinlock/core: move the dereference below the NULL test The dereference should be moved below the NULL test. spatch with a semantic match is used to found this. (http://coccinelle.lip6.fr/) Signed-off-by: Wei Yongjun Signed-off-by: Ohad Ben-Cohen --- diff --git a/drivers/hwspinlock/hwspinlock_core.c b/drivers/hwspinlock/hwspinlock_core.c index 1201a15784c3..db713c0dfba4 100644 --- a/drivers/hwspinlock/hwspinlock_core.c +++ b/drivers/hwspinlock/hwspinlock_core.c @@ -552,7 +552,7 @@ EXPORT_SYMBOL_GPL(hwspin_lock_request_specific); */ int hwspin_lock_free(struct hwspinlock *hwlock) { - struct device *dev = hwlock->bank->dev; + struct device *dev; struct hwspinlock *tmp; int ret; @@ -561,6 +561,7 @@ int hwspin_lock_free(struct hwspinlock *hwlock) return -EINVAL; } + dev = hwlock->bank->dev; mutex_lock(&hwspinlock_tree_lock); /* make sure the hwspinlock is used */