[PATCH 2/3] SCSI-debug: Less function calls in scsi_debug_init() after error detection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 6 Feb 2015 17:48:34 +0100

The vfree() function was called in two cases by the scsi_debug_init() function
during error handling even if the passed variables "dif_storep" and
"map_storep" contained null pointers eventually.

This implementation detail could be improved by the introduction of two
jump labels.

Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
---
 drivers/scsi/scsi_debug.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 9e4add7..756b7be 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -4887,7 +4887,7 @@ static int __init scsi_debug_init(void)
 		if (dif_storep == NULL) {
 			pr_err("%s: out of mem. (DIX)\n", __func__);
 			ret = -ENOMEM;
-			goto free_vm;
+			goto free_fake;
 		}
 
 		memset(dif_storep, 0xff, dif_size);
@@ -4920,7 +4920,7 @@ static int __init scsi_debug_init(void)
 		if (map_storep == NULL) {
 			pr_err("%s: out of mem. (MAP)\n", __func__);
 			ret = -ENOMEM;
-			goto free_vm;
+			goto free_dif;
 		}
 
 		bitmap_zero(map_storep, map_size);
@@ -4934,7 +4934,7 @@ static int __init scsi_debug_init(void)
 	if (IS_ERR(pseudo_primary)) {
 		pr_warn("%s: root_device_register() error\n", __func__);
 		ret = PTR_ERR(pseudo_primary);
-		goto free_vm;
+		goto free_map;
 	}
 	ret = bus_register(&pseudo_lld_bus);
 	if (ret < 0) {
@@ -4968,9 +4968,11 @@ bus_unreg:
 	bus_unregister(&pseudo_lld_bus);
 dev_unreg:
 	root_device_unregister(pseudo_primary);
-free_vm:
+free_map:
 	vfree(map_storep);
+free_dif:
 	vfree(dif_storep);
+free_fake:
 	vfree(fake_storep);
 	return ret;
 }
-- 
2.2.2

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux