public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* question about del_gendisk function use in drivers/scsi/sr.c
@ 2010-03-01 18:27 Alexander Strakh
  0 siblings, 0 replies; only message in thread
From: Alexander Strakh @ 2010-03-01 18:27 UTC (permalink / raw)
  To: Drew Eckhardt, Thomas Quinot, Gerd Knorr, Jens Axboe,
	Richard Gooch
  Cc: Eric Youngdale

        KERNEL_VERSION: 2.6.33
        SUBJECT: question about del_gendisk function use
        SUBSCRIBE:
        In driver drivers/scsi/sr.c in function sr_probe:

1. In line 588 we call  alloc_disk(1);
2. If in line 593 function find_first_zero_bit returns SR_DISKS then we goto 
label fail_put (line 597).
3. In line 652 we call put_disk. But in some other drivers del_gendisk is 
called before put_disk. Why didn't we call del_gendisk before put_disk here? 
Is it an error?

570 static int sr_probe(struct device *dev)
571 {
572         struct scsi_device *sdev = to_scsi_device(dev);
573         struct gendisk *disk;
574         struct scsi_cd *cd;
575         int minor, error;
576
577         error = -ENODEV;
578         if (sdev->type != TYPE_ROM && sdev->type != TYPE_WORM)
579                 goto fail;
580
581         error = -ENOMEM;
582         cd = kzalloc(sizeof(*cd), GFP_KERNEL);
583         if (!cd)
584                 goto fail;
585
586         kref_init(&cd->kref);
587
588         disk = alloc_disk(1);
589         if (!disk)
590                 goto fail_free;
591
592         spin_lock(&sr_index_lock);
593         minor = find_first_zero_bit(sr_index_bits, SR_DISKS);
594         if (minor == SR_DISKS) {
595                 spin_unlock(&sr_index_lock);
596                 error = -EBUSY;
597                 goto fail_put;
598         }

...
641                 goto fail_put;
642
643         dev_set_drvdata(dev, cd);
644         disk->flags |= GENHD_FL_REMOVABLE;
645         add_disk(disk);
646
647         sdev_printk(KERN_DEBUG, sdev,
648                     "Attached scsi CD-ROM %s\n", cd->cdi.name);
649         return 0;
650
651 fail_put:
652         put_disk(disk);
653 fail_free:
654         kfree(cd);
655 fail:
656         return error;
...

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-03-01 15:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-01 18:27 question about del_gendisk function use in drivers/scsi/sr.c Alexander Strakh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox