On Thu, May 02, 2019 at 01:50:22AM +0000, Parav Pandit wrote: > Hi Leon, > > > -----Original Message----- > > From: linux-rdma-owner@xxxxxxxxxxxxxxx <linux-rdma- > > owner@xxxxxxxxxxxxxxx> On Behalf Of Leon Romanovsky > > Sent: Wednesday, May 1, 2019 12:31 PM > > To: Jason Gunthorpe <jgg@xxxxxxxxxxxx> > > Cc: Doug Ledford <dledford@xxxxxxxxxx>; RDMA mailing list <linux- > > rdma@xxxxxxxxxxxxxxx> > > Subject: Re: [PATCH rdma-next] RDMA/device: Don't fire uevent before > > device is fully initialized > > > > On Wed, May 01, 2019 at 01:28:55PM +0000, Jason Gunthorpe wrote: > > > On Wed, May 01, 2019 at 08:46:19AM +0300, Leon Romanovsky wrote: > > > > From: Leon Romanovsky <leonro@xxxxxxxxxxxx> > > > > > > > > When the refcount is 0 the device is invisible to netlink. However > > > > in the patch below the refcount = 1 was moved to after the device_add(). > > > > This creates a race where userspace can issue a netlink query after > > > > the > > > > device_add() event and not see the device as visible. > > > > > > > > Ensure that no uevent is fired before device is fully registered. > > > > > > > > Fixes: d79af7242bb2 ("RDMA/device: Expose ib_device_try_get(()") > > > > Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx> > > > > drivers/infiniband/core/device.c | 12 ++++++++++++ > > > > 1 file changed, 12 insertions(+) > > > > > > > > diff --git a/drivers/infiniband/core/device.c > > > > b/drivers/infiniband/core/device.c > > > > index 8ae4906a60e7..4cdc8588df7f 100644 > > > > +++ b/drivers/infiniband/core/device.c > > > > @@ -808,6 +808,7 @@ static int add_one_compat_dev(struct ib_device > > *device, > > > > cdev->dev.release = compatdev_release; > > > > dev_set_name(&cdev->dev, "%s", dev_name(&device->dev)); > > > > > > > > + dev_set_uevent_suppress(&device->dev, true); > > > > ret = device_add(&cdev->dev); > > > > if (ret) > > > > goto add_err; > > > > > > compat devices definitely should not be doing this.. > > > > Why? They have the same problematic pattern: > > device_add -> ..... -> enable_device. > > > compat devices are added in enable_device_and_get() after refcount is set. > ib_register_device() > enable_device_and_get() > refcount=2 > [...] > add_compat_devs() ok, I will return to my original patch before I changed its as a response for review comments. Thanks