Re: [PATCH v2 11/15] leds: trigger: blkdev: Enable linking block devices to LEDs

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

 



On 9/10/21 1:48 AM, Greg KH wrote:
+/* Gets or allocs & initializes the blkdev disk for a gendisk */
+static int blkdev_get_disk(struct gendisk *const gd)
+{
+	struct ledtrig_blkdev_disk *disk;
+	struct kobject *dir;
+
+	if (gd->ledtrig != NULL) {
+		kobject_get(gd->ledtrig->dir);

When do you decrement this kobject?

That happens in blkdev_disk_unlink_locked() at line 399.  (Also in the
error path in blkdev_put_disk(), called at line 321.)

Looking at this now, blkdev_disk_unlink_locked() should be calling
blkdev_put_disk(), rather than calling kobject_put() directly.  I'll fix
that.

+static void blkdev_put_disk(struct ledtrig_blkdev_disk *const disk)
+{
+	kobject_put(disk->dir);
+
+	if (hlist_empty(&disk->leds)) {
+		disk->gd->ledtrig = NULL;
+		kfree(disk);

This should happen in the kobject release function, not here, right?

If you're referring to the kfree() call, it's freeing the
ledtrig_blkdev_disk structure, not the gendisk.  I use "gd" for gendisk
pointers and "disk" for ledtrig_blkdev_disk pointers.

Did you try this out with removable block devices yet?

Absolutely.  I've tested removing both block devices and (user space)
LEDs.

--
========================================================================
                 In Soviet Russia, Google searches you!
========================================================================



[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