aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorFUJITA Tomonori <tomof@acm.org>2008-01-23 09:34:35 -0500
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-01-23 14:44:47 -0500
commita3d2c2e8f5e01e185013d8f944c0a26fdc558ad8 (patch)
tree9270b0630358e2f8a014415d84db98c49770211d /drivers/scsi
parenta43cf0f3511585493e3c948f7ec62f659486d0b3 (diff)
[SCSI] ch: handle class_device_create failure properly
When class_device_create fails, ch_probe needs to fail too. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/ch.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index cead0f5379c5..765f2fc001aa 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -913,29 +913,37 @@ static long ch_ioctl_compat(struct file * file,
913static int ch_probe(struct device *dev) 913static int ch_probe(struct device *dev)
914{ 914{
915 struct scsi_device *sd = to_scsi_device(dev); 915 struct scsi_device *sd = to_scsi_device(dev);
916 struct class_device *class_dev;
916 scsi_changer *ch; 917 scsi_changer *ch;
917 918
918 if (sd->type != TYPE_MEDIUM_CHANGER) 919 if (sd->type != TYPE_MEDIUM_CHANGER)
919 return -ENODEV; 920 return -ENODEV;
920 921
921 ch = kzalloc(sizeof(*ch), GFP_KERNEL); 922 ch = kzalloc(sizeof(*ch), GFP_KERNEL);
922 if (NULL == ch) 923 if (NULL == ch)
923 return -ENOMEM; 924 return -ENOMEM;
924 925
925 ch->minor = ch_devcount; 926 ch->minor = ch_devcount;
926 sprintf(ch->name,"ch%d",ch->minor); 927 sprintf(ch->name,"ch%d",ch->minor);
928
929 class_dev = class_device_create(ch_sysfs_class, NULL,
930 MKDEV(SCSI_CHANGER_MAJOR, ch->minor),
931 dev, "s%s", ch->name);
932 if (IS_ERR(class_dev)) {
933 printk(KERN_WARNING "ch%d: class_device_create failed\n",
934 ch->minor);
935 kfree(ch);
936 return PTR_ERR(class_dev);
937 }
938
927 mutex_init(&ch->lock); 939 mutex_init(&ch->lock);
928 ch->device = sd; 940 ch->device = sd;
929 ch_readconfig(ch); 941 ch_readconfig(ch);
930 if (init) 942 if (init)
931 ch_init_elem(ch); 943 ch_init_elem(ch);
932 944
933 class_device_create(ch_sysfs_class, NULL,
934 MKDEV(SCSI_CHANGER_MAJOR,ch->minor),
935 dev, "s%s", ch->name);
936
937 sdev_printk(KERN_INFO, sd, "Attached scsi changer %s\n", ch->name); 945 sdev_printk(KERN_INFO, sd, "Attached scsi changer %s\n", ch->name);
938 946
939 spin_lock(&ch_devlist_lock); 947 spin_lock(&ch_devlist_lock);
940 list_add_tail(&ch->list,&ch_devlist); 948 list_add_tail(&ch->list,&ch_devlist);
941 ch_devcount++; 949 ch_devcount++;