On 2021/12/21 4:16, Luis Chamberlain wrote: > The kobject_alive() tells us if at least the device_add() had the > kobject_add() complete. Testing with error injection @@ -3284,6 +3284,9 @@ int device_add(struct device *dev) if (!dev) goto done; + if (!strcmp(current->comm, "a.out")) + goto done; + if (!dev->p) { error = device_private_init(dev); if (error) told me that kref count is 1 when reaching the out_disk_release_events label. Thus, if (!kobject_alive(&ddev->kobj)) seems wrong. Christoph proposed deferring disk_alloc_events(). If it is safe to defer disk_alloc_events(), that can be a fix. But I don't know if there is a path which can invoke disk event functions (e.g. disk_block_events() from blkdev_get_by_dev()) between device_add() and disk_alloc_events(). I didn't find a path, but at least the device file and some of sysfs files are already visible before disk_alloc_events() is called...