Re: [PATCH] block: fix error handling for device_add_disk

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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...



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux