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