* re: NFC: netlink: Implement vendor command support
@ 2015-06-26 9:30 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2015-06-26 9:30 UTC (permalink / raw)
To: sameo; +Cc: linux-wireless
Hello Samuel Ortiz,
The patch 9e58095f9660: "NFC: netlink: Implement vendor command
support" from Oct 14, 2014, leads to the following static checker
warning:
net/nfc/netlink.c:1522 nfc_genl_vendor_cmd()
warn: can 'data' even be NULL?
net/nfc/netlink.c
1498 static int nfc_genl_vendor_cmd(struct sk_buff *skb,
1499 struct genl_info *info)
1500 {
1501 struct nfc_dev *dev;
1502 struct nfc_vendor_cmd *cmd;
1503 u32 dev_idx, vid, subcmd;
1504 u8 *data;
1505 size_t data_len;
1506 int i;
1507
1508 if (!info->attrs[NFC_ATTR_DEVICE_INDEX] ||
1509 !info->attrs[NFC_ATTR_VENDOR_ID] ||
1510 !info->attrs[NFC_ATTR_VENDOR_SUBCMD])
1511 return -EINVAL;
1512
1513 dev_idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
1514 vid = nla_get_u32(info->attrs[NFC_ATTR_VENDOR_ID]);
1515 subcmd = nla_get_u32(info->attrs[NFC_ATTR_VENDOR_SUBCMD]);
1516
1517 dev = nfc_get_device(dev_idx);
1518 if (!dev || !dev->vendor_cmds || !dev->n_vendor_cmds)
1519 return -ENODEV;
1520
1521 data = nla_data(info->attrs[NFC_ATTR_VENDOR_DATA]);
1522 if (data) {
1523 data_len = nla_len(info->attrs[NFC_ATTR_VENDOR_DATA]);
1524 if (data_len == 0)
1525 return -EINVAL;
1526 } else {
1527 data_len = 0;
1528 }
nla_data() never returns NULL. The test should probably be:
if (info->attrs[NFC_ATTR_VENDOR_DATA]) {
Why is specifying data_len == 0 invalid?
1529
1530 for (i = 0; i < dev->n_vendor_cmds; i++) {
1531 cmd = &dev->vendor_cmds[i];
1532
1533 if (cmd->vendor_id != vid || cmd->subcmd != subcmd)
1534 continue;
1535
1536 return cmd->doit(dev, data, data_len);
1537 }
1538
1539 return -EOPNOTSUPP;
1540 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-06-26 9:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-26 9:30 NFC: netlink: Implement vendor command support Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).