Skip to content

Commit 6f7f657

Browse files
Alexander AringStefan-Schmidt
authored andcommitted
net: ieee802154: nl-mac: fix check on panid
This patch fixes a null pointer derefence for panid handle by move the check for the netlink variable directly before accessing them. Reported-by: [email protected] Signed-off-by: Alexander Aring <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stefan Schmidt <[email protected]>
1 parent 27c7468 commit 6f7f657

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

net/ieee802154/nl-mac.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -551,9 +551,7 @@ ieee802154_llsec_parse_key_id(struct genl_info *info,
551551
desc->mode = nla_get_u8(info->attrs[IEEE802154_ATTR_LLSEC_KEY_MODE]);
552552

553553
if (desc->mode == IEEE802154_SCF_KEY_IMPLICIT) {
554-
if (!info->attrs[IEEE802154_ATTR_PAN_ID] &&
555-
!(info->attrs[IEEE802154_ATTR_SHORT_ADDR] ||
556-
info->attrs[IEEE802154_ATTR_HW_ADDR]))
554+
if (!info->attrs[IEEE802154_ATTR_PAN_ID])
557555
return -EINVAL;
558556

559557
desc->device_addr.pan_id = nla_get_shortaddr(info->attrs[IEEE802154_ATTR_PAN_ID]);
@@ -562,6 +560,9 @@ ieee802154_llsec_parse_key_id(struct genl_info *info,
562560
desc->device_addr.mode = IEEE802154_ADDR_SHORT;
563561
desc->device_addr.short_addr = nla_get_shortaddr(info->attrs[IEEE802154_ATTR_SHORT_ADDR]);
564562
} else {
563+
if (!info->attrs[IEEE802154_ATTR_HW_ADDR])
564+
return -EINVAL;
565+
565566
desc->device_addr.mode = IEEE802154_ADDR_LONG;
566567
desc->device_addr.extended_addr = nla_get_hwaddr(info->attrs[IEEE802154_ATTR_HW_ADDR]);
567568
}

0 commit comments

Comments
 (0)