On Tue, Feb 26, 2019 at 02:01:47PM +0200, Leon Romanovsky wrote: > @@ -658,7 +658,7 @@ static int nldev_set_doit(struct sk_buff *skb, struct nlmsghdr *nlh, > return -EINVAL; > > index = nla_get_u32(tb[RDMA_NLDEV_ATTR_DEV_INDEX]); > - device = ib_device_get_by_index(index); > + device = ib_device_get_by_index(sock_net(skb->sk), index); > if (!device) > return -EINVAL; > > @@ -685,6 +685,14 @@ static int _nldev_get_dumpit(struct ib_device *device, > if (idx < start) > return 0; > > + if (!ib_device_try_get(device)) > + return 0; Why is this added? _nldev_get_dumpit is only called from ib_enum_all_devs which is holding the devices_rwsem I think the test for rdma_dev_access_netns should just be part of ib_enum_all_devs(), not in each of the callbacks. > + if (!rdma_dev_access_netns(device, sock_net(skb->sk))) { > + ib_device_put(device); > + return 0; This placement is wrong, it should be in ib_enum_all_devs() and 'idx' should not include devices outside the namespace. ie should should not be holes in the idx numbering for devices which are invsible. Jason