Skip to content

Commit 1c9043a

Browse files
mustafakismailjgunthorpe
authored andcommitted
RDMA/irdma: Fix possible crash due to NULL netdev in notifier
For some net events in irdma_net_event notifier, the netdev can be NULL which will cause a crash in rdma_vlan_dev_real_dev. Fix this by moving all processing to the NETEVENT_NEIGH_UPDATE case where the netdev is guaranteed to not be NULL. Fixes: 6702bc1 ("RDMA/irdma: Fix netdev notifications for vlan's") Link: https://lore.kernel.org/r/20220425181703.1634-4-shiraz.saleem@intel.com Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com> Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent 2df6d89 commit 1c9043a

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

drivers/infiniband/hw/irdma/utils.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -258,18 +258,16 @@ int irdma_net_event(struct notifier_block *notifier, unsigned long event,
258258
u32 local_ipaddr[4] = {};
259259
bool ipv4 = true;
260260

261-
real_dev = rdma_vlan_dev_real_dev(netdev);
262-
if (!real_dev)
263-
real_dev = netdev;
264-
265-
ibdev = ib_device_get_by_netdev(real_dev, RDMA_DRIVER_IRDMA);
266-
if (!ibdev)
267-
return NOTIFY_DONE;
268-
269-
iwdev = to_iwdev(ibdev);
270-
271261
switch (event) {
272262
case NETEVENT_NEIGH_UPDATE:
263+
real_dev = rdma_vlan_dev_real_dev(netdev);
264+
if (!real_dev)
265+
real_dev = netdev;
266+
ibdev = ib_device_get_by_netdev(real_dev, RDMA_DRIVER_IRDMA);
267+
if (!ibdev)
268+
return NOTIFY_DONE;
269+
270+
iwdev = to_iwdev(ibdev);
273271
p = (__be32 *)neigh->primary_key;
274272
if (neigh->tbl->family == AF_INET6) {
275273
ipv4 = false;
@@ -290,13 +288,12 @@ int irdma_net_event(struct notifier_block *notifier, unsigned long event,
290288
irdma_manage_arp_cache(iwdev->rf, neigh->ha,
291289
local_ipaddr, ipv4,
292290
IRDMA_ARP_DELETE);
291+
ib_device_put(ibdev);
293292
break;
294293
default:
295294
break;
296295
}
297296

298-
ib_device_put(ibdev);
299-
300297
return NOTIFY_DONE;
301298
}
302299

0 commit comments

Comments
 (0)