]> xenbits.xensource.com Git - people/aperard/linux.git/commitdiff
net: ice: Fix potential NULL pointer dereference in ice_bridge_setlink()
authorRand Deeb <rand.sec96@gmail.com>
Wed, 28 Feb 2024 15:54:48 +0000 (18:54 +0300)
committerSasha Levin <sashal@kernel.org>
Fri, 15 Mar 2024 14:48:15 +0000 (10:48 -0400)
[ Upstream commit 06e456a05d669ca30b224b8ed962421770c1496c ]

The function ice_bridge_setlink() may encounter a NULL pointer dereference
if nlmsg_find_attr() returns NULL and br_spec is dereferenced subsequently
in nla_for_each_nested(). To address this issue, add a check to ensure that
br_spec is not NULL before proceeding with the nested attribute iteration.

Fixes: b1edc14a3fbf ("ice: Implement ice_bridge_getlink and ice_bridge_setlink")
Signed-off-by: Rand Deeb <rand.sec96@gmail.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/intel/ice/ice_main.c

index ab46cfca4028d703f16643ce03aa693f357ade58..3117f65253b37edf3452a1785c3eabb6ca99b564 100644 (file)
@@ -7681,6 +7681,8 @@ ice_bridge_setlink(struct net_device *dev, struct nlmsghdr *nlh,
        pf_sw = pf->first_sw;
        /* find the attribute in the netlink message */
        br_spec = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), IFLA_AF_SPEC);
+       if (!br_spec)
+               return -EINVAL;
 
        nla_for_each_nested(attr, br_spec, rem) {
                __u16 mode;