lkml.org 
[lkml]   [2021]   [Sep]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2 11/15] leds: trigger: blkdev: Enable linking block devices to LEDs
From
Date
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!
========================================================================

\
 
 \ /
  Last update: 2021-09-10 18:26    [W:0.052 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site