NFC: delete null dereference
authorJulia Lawall <Julia.Lawall@lip6.fr>
Sat, 17 Oct 2015 09:32:19 +0000 (11:32 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Mon, 19 Oct 2015 18:10:37 +0000 (20:10 +0200)
The exit label performs device_unlock(&dev->dev);, which will fail when dev
is NULL, and nfc_put_device(dev);, which is not useful when dev is NULL, so
just exit the function immediately.

Problem found using scripts/coccinelle/null/deref_null.cocci

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
net/nfc/netlink.c

index 853172c27f68043f47ddd45a1e778e9e87efd163..f04053295ff122fdf588a749ab2202b712331c42 100644 (file)
@@ -1109,10 +1109,8 @@ static int nfc_genl_llc_sdreq(struct sk_buff *skb, struct genl_info *info)
        idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
 
        dev = nfc_get_device(idx);
-       if (!dev) {
-               rc = -ENODEV;
-               goto exit;
-       }
+       if (!dev)
+               return -ENODEV;
 
        device_lock(&dev->dev);
 
This page took 0.025368 seconds and 5 git commands to generate.