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: [email protected]
Signed-off-by: Christophe Ricard <[email protected]>
---
 net/nfc/netlink.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c
index f85f37e..dcb858e 100644
--- a/net/nfc/netlink.c
+++ b/net/nfc/netlink.c
@@ -1450,8 +1450,6 @@ nla_put_failure:
 free_msg:
        nlmsg_free(msg);
        kfree(ctx);
-
-       return;
 }
 
 static int nfc_genl_se_io(struct sk_buff *skb, struct genl_info *info)
@@ -1518,8 +1516,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;
@@ -1529,7 +1527,6 @@ static int nfc_genl_vendor_cmd(struct sk_buff *skb,
 
        for (i = 0; i < dev->n_vendor_cmds; i++) {
                cmd = &dev->vendor_cmds[i];
-
                if (cmd->vendor_id != vid || cmd->subcmd != subcmd)
                        continue;
 
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to