nfc: netlink: Add check on NFC_ATTR_VENDOR_DATA
authorChristophe Ricard <christophe.ricard@gmail.com>
Fri, 14 Aug 2015 20:33:40 +0000 (22:33 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Sun, 16 Aug 2015 23:36:17 +0000 (01:36 +0200)
NFC_ATTR_VENDOR_DATA is an optional vendor_cmd argument.
The current code was potentially using a non existing argument
leading to potential catastrophic results.

Cc: stable@vger.kernel.org
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
net/nfc/netlink.c

index f85f37ed19b23d0b9509e243d2c56b3070c6cbb6..81dfaaacfc4dec6621835614fde07d4f9d6c1d58 100644 (file)
@@ -1518,8 +1518,8 @@ static int nfc_genl_vendor_cmd(struct sk_buff *skb,
        if (!dev || !dev->vendor_cmds || !dev->n_vendor_cmds)
                return -ENODEV;
 
-       data = nla_data(info->attrs[NFC_ATTR_VENDOR_DATA]);
-       if (data) {
+       if (info->attrs[NFC_ATTR_VENDOR_DATA]) {
+               data = nla_data(info->attrs[NFC_ATTR_VENDOR_DATA]);
                data_len = nla_len(info->attrs[NFC_ATTR_VENDOR_DATA]);
                if (data_len == 0)
                        return -EINVAL;