X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fide%2Fide-tape.c;h=1bce84b566304115c2834a1742f03284e2c25ce9;hb=2fdc86901d2ab30a12402b46238951d2a7891590;hp=82c2afe4d28a3a081a30fd5755de01fb17fc2e44;hpb=1e24b15b267293567a8d752721c7ae63f281325a;p=linux-2.6 diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 82c2afe4d2..1bce84b566 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) mutex_lock(&idetape_ref_mutex); tape = ide_tape_g(disk); if (tape) { - kref_get(&tape->kref); - if (ide_device_get(tape->drive)) { - kref_put(&tape->kref, ide_tape_release); + if (ide_device_get(tape->drive)) tape = NULL; - } + else + kref_get(&tape->kref); } mutex_unlock(&idetape_ref_mutex); return tape; @@ -343,9 +342,11 @@ static struct ide_tape_obj *ide_tape_get(struct gendisk *disk) static void ide_tape_put(struct ide_tape_obj *tape) { + ide_drive_t *drive = tape->drive; + mutex_lock(&idetape_ref_mutex); - ide_device_put(tape->drive); kref_put(&tape->kref, ide_tape_release); + ide_device_put(drive); mutex_unlock(&idetape_ref_mutex); }