From: Julia Lawall Date: Sat, 17 Oct 2015 09:32:19 +0000 (+0200) Subject: NFC: delete null dereference X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=9abebb8a10ce93db45327bd3a4d06801e6db92f2;p=openwrt%2Fstaging%2Fblogic.git NFC: delete null dereference 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 Signed-off-by: Samuel Ortiz --- diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c index 853172c27f68..f04053295ff1 100644 --- a/net/nfc/netlink.c +++ b/net/nfc/netlink.c @@ -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);