Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a3d2c2e8 authored by FUJITA Tomonori's avatar FUJITA Tomonori Committed by James Bottomley
Browse files

[SCSI] ch: handle class_device_create failure properly



When class_device_create fails, ch_probe needs to fail too.

Signed-off-by: default avatarFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@HansenPartnership.com>
parent a43cf0f3
Loading
Loading
Loading
Loading
+15 −7
Original line number Diff line number Diff line
@@ -913,6 +913,7 @@ static long ch_ioctl_compat(struct file * file,
static int ch_probe(struct device *dev)
{
	struct scsi_device *sd = to_scsi_device(dev);
	struct class_device *class_dev;
	scsi_changer *ch;

	if (sd->type != TYPE_MEDIUM_CHANGER)
@@ -924,16 +925,23 @@ static int ch_probe(struct device *dev)

	ch->minor = ch_devcount;
	sprintf(ch->name,"ch%d",ch->minor);

	class_dev = class_device_create(ch_sysfs_class, NULL,
					MKDEV(SCSI_CHANGER_MAJOR, ch->minor),
					dev, "s%s", ch->name);
	if (IS_ERR(class_dev)) {
		printk(KERN_WARNING "ch%d: class_device_create failed\n",
		       ch->minor);
		kfree(ch);
		return PTR_ERR(class_dev);
	}

	mutex_init(&ch->lock);
	ch->device = sd;
	ch_readconfig(ch);
	if (init)
		ch_init_elem(ch);

	class_device_create(ch_sysfs_class, NULL,
			    MKDEV(SCSI_CHANGER_MAJOR,ch->minor),
			    dev, "s%s", ch->name);

	sdev_printk(KERN_INFO, sd, "Attached scsi changer %s\n", ch->name);

	spin_lock(&ch_devlist_lock);