diff options
Diffstat (limited to 'drivers/ide/ide-tape.c')
-rw-r--r-- | drivers/ide/ide-tape.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 82c2afe4d28a..1bce84b56630 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -331,11 +331,10 @@ static struct ide_tape_obj *ide_tape_get(struct gendisk *disk) | |||
331 | mutex_lock(&idetape_ref_mutex); | 331 | mutex_lock(&idetape_ref_mutex); |
332 | tape = ide_tape_g(disk); | 332 | tape = ide_tape_g(disk); |
333 | if (tape) { | 333 | if (tape) { |
334 | kref_get(&tape->kref); | 334 | if (ide_device_get(tape->drive)) |
335 | if (ide_device_get(tape->drive)) { | ||
336 | kref_put(&tape->kref, ide_tape_release); | ||
337 | tape = NULL; | 335 | tape = NULL; |
338 | } | 336 | else |
337 | kref_get(&tape->kref); | ||
339 | } | 338 | } |
340 | mutex_unlock(&idetape_ref_mutex); | 339 | mutex_unlock(&idetape_ref_mutex); |
341 | return tape; | 340 | return tape; |
@@ -343,9 +342,11 @@ static struct ide_tape_obj *ide_tape_get(struct gendisk *disk) | |||
343 | 342 | ||
344 | static void ide_tape_put(struct ide_tape_obj *tape) | 343 | static void ide_tape_put(struct ide_tape_obj *tape) |
345 | { | 344 | { |
345 | ide_drive_t *drive = tape->drive; | ||
346 | |||
346 | mutex_lock(&idetape_ref_mutex); | 347 | mutex_lock(&idetape_ref_mutex); |
347 | ide_device_put(tape->drive); | ||
348 | kref_put(&tape->kref, ide_tape_release); | 348 | kref_put(&tape->kref, ide_tape_release); |
349 | ide_device_put(drive); | ||
349 | mutex_unlock(&idetape_ref_mutex); | 350 | mutex_unlock(&idetape_ref_mutex); |
350 | } | 351 | } |
351 | 352 | ||