Skip to content

Commit ec4fe4b

Browse files
ftang1jgunthorpe
authored andcommitted
i40iw: Avoid panic when handling the inetdev event
There is a panic reported that on a system with x722 ethernet, when doing the operations like: # ip link add br0 type bridge # ip link set eno1 master br0 # systemctl restart systemd-networkd The system will panic "BUG: unable to handle kernel null pointer dereference at 0000000000000034", with call chain: i40iw_inetaddr_event notifier_call_chain blocking_notifier_call_chain notifier_call_chain __inet_del_ifa inet_rtm_deladdr rtnetlink_rcv_msg netlink_rcv_skb rtnetlink_rcv netlink_unicast netlink_sendmsg sock_sendmsg __sys_sendto It is caused by "local_ipaddr = ntohl(in->ifa_list->ifa_address)", while the in->ifa_list is NULL. So add a check for the "in->ifa_list == NULL" case, and skip the ARP operation accordingly. Signed-off-by: Feng Tang <feng.tang@intel.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
1 parent cd27287 commit ec4fe4b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

drivers/infiniband/hw/i40iw/i40iw_utils.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,12 @@ int i40iw_inetaddr_event(struct notifier_block *notifier,
173173

174174
rcu_read_lock();
175175
in = __in_dev_get_rcu(upper_dev);
176-
local_ipaddr = ntohl(in->ifa_list->ifa_address);
176+
177+
if (!in->ifa_list)
178+
local_ipaddr = 0;
179+
else
180+
local_ipaddr = ntohl(in->ifa_list->ifa_address);
181+
177182
rcu_read_unlock();
178183
} else {
179184
local_ipaddr = ntohl(ifa->ifa_address);
@@ -185,6 +190,11 @@ int i40iw_inetaddr_event(struct notifier_block *notifier,
185190
case NETDEV_UP:
186191
/* Fall through */
187192
case NETDEV_CHANGEADDR:
193+
194+
/* Just skip if no need to handle ARP cache */
195+
if (!local_ipaddr)
196+
break;
197+
188198
i40iw_manage_arp_cache(iwdev,
189199
netdev->dev_addr,
190200
&local_ipaddr,

0 commit comments

Comments
 (0)