ide: fix refcounting in device drivers
During host driver module removal del_gendisk() results in a final put on drive->gendev and freeing the drive by drive_release_dev(). Convert device drivers from using struct kref to use struct device so device driver's object holds reference on ->gendev and prevents drive from prematurely going away. Also fix ->remove methods to not erroneously drop reference on a host driver by using only put_device() instead of ide*_put(). Reported-by: Stanislaw Gruszka <stf_xl@wp.pl> Tested-by: Stanislaw Gruszka <stf_xl@wp.pl> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
This commit is contained in:
@ -663,7 +663,7 @@ typedef struct ide_drive_s ide_drive_t;
|
||||
#define to_ide_device(dev) container_of(dev, ide_drive_t, gendev)
|
||||
|
||||
#define to_ide_drv(obj, cont_type) \
|
||||
container_of(obj, struct cont_type, kref)
|
||||
container_of(obj, struct cont_type, dev)
|
||||
|
||||
#define ide_drv_g(disk, cont_type) \
|
||||
container_of((disk)->private_data, struct cont_type, driver)
|
||||
|
Reference in New Issue
Block a user