Messages in this thread | | | Subject | Re: [PATCH v2 11/15] leds: trigger: blkdev: Enable linking block devices to LEDs | From | Ian Pilcher <> | Date | Fri, 10 Sep 2021 11:25:14 -0500 |
| |
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! ========================================================================
| |