aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sg.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/sg.c')
-rw-r--r--drivers/scsi/sg.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 4e607d3065b..65eef33846b 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1401,6 +1401,7 @@ sg_add(struct class_device *cl_dev, struct class_interface *cl_intf)
1401 Sg_device *sdp = NULL; 1401 Sg_device *sdp = NULL;
1402 struct cdev * cdev = NULL; 1402 struct cdev * cdev = NULL;
1403 int error, k; 1403 int error, k;
1404 unsigned long iflags;
1404 1405
1405 disk = alloc_disk(1); 1406 disk = alloc_disk(1);
1406 if (!disk) { 1407 if (!disk) {
@@ -1428,7 +1429,7 @@ sg_add(struct class_device *cl_dev, struct class_interface *cl_intf)
1428 1429
1429 error = cdev_add(cdev, MKDEV(SCSI_GENERIC_MAJOR, k), 1); 1430 error = cdev_add(cdev, MKDEV(SCSI_GENERIC_MAJOR, k), 1);
1430 if (error) 1431 if (error)
1431 goto out; 1432 goto cdev_add_err;
1432 1433
1433 sdp->cdev = cdev; 1434 sdp->cdev = cdev;
1434 if (sg_sysfs_valid) { 1435 if (sg_sysfs_valid) {
@@ -1455,6 +1456,13 @@ sg_add(struct class_device *cl_dev, struct class_interface *cl_intf)
1455 1456
1456 return 0; 1457 return 0;
1457 1458
1459cdev_add_err:
1460 write_lock_irqsave(&sg_dev_arr_lock, iflags);
1461 kfree(sg_dev_arr[k]);
1462 sg_dev_arr[k] = NULL;
1463 sg_nr_dev--;
1464 write_unlock_irqrestore(&sg_dev_arr_lock, iflags);
1465
1458out: 1466out:
1459 put_disk(disk); 1467 put_disk(disk);
1460 if (cdev) 1468 if (cdev)