diff options
Diffstat (limited to 'drivers/ide/ide-cd.c')
-rw-r--r-- | drivers/ide/ide-cd.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index e617cf08aef6..e19caa1453a3 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -66,11 +66,11 @@ static struct cdrom_info *ide_cd_get(struct gendisk *disk) | |||
66 | mutex_lock(&idecd_ref_mutex); | 66 | mutex_lock(&idecd_ref_mutex); |
67 | cd = ide_cd_g(disk); | 67 | cd = ide_cd_g(disk); |
68 | if (cd) { | 68 | if (cd) { |
69 | kref_get(&cd->kref); | 69 | if (ide_device_get(cd->drive)) |
70 | if (ide_device_get(cd->drive)) { | ||
71 | kref_put(&cd->kref, ide_cd_release); | ||
72 | cd = NULL; | 70 | cd = NULL; |
73 | } | 71 | else |
72 | kref_get(&cd->kref); | ||
73 | |||
74 | } | 74 | } |
75 | mutex_unlock(&idecd_ref_mutex); | 75 | mutex_unlock(&idecd_ref_mutex); |
76 | return cd; | 76 | return cd; |
@@ -78,9 +78,11 @@ static struct cdrom_info *ide_cd_get(struct gendisk *disk) | |||
78 | 78 | ||
79 | static void ide_cd_put(struct cdrom_info *cd) | 79 | static void ide_cd_put(struct cdrom_info *cd) |
80 | { | 80 | { |
81 | ide_drive_t *drive = cd->drive; | ||
82 | |||
81 | mutex_lock(&idecd_ref_mutex); | 83 | mutex_lock(&idecd_ref_mutex); |
82 | ide_device_put(cd->drive); | ||
83 | kref_put(&cd->kref, ide_cd_release); | 84 | kref_put(&cd->kref, ide_cd_release); |
85 | ide_device_put(drive); | ||
84 | mutex_unlock(&idecd_ref_mutex); | 86 | mutex_unlock(&idecd_ref_mutex); |
85 | } | 87 | } |
86 | 88 | ||