scsi: target: return -ENOMEM when kzalloc failed
Subsystems (2)
PATCH 1/1 scsi: target: return -ENOMEM when kzalloc failed
The driver is using -1 instead of the -ENOMEM defined macro to specify that a buffer allocation failed.
drivers/target/iscsi/iscsi_target.c:691 iscsi_target_init_module() warn: returning -1 instead of -ENOMEM is sloppy.
--- drivers/target/iscsi/iscsi_target.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/target/iscsi/iscsi_target.c +1 -1
@@ -688,7 +688,7 @@ static int __init iscsi_target_init_module(void)pr_debug ("iSCSI-Target " ISCSIT_VERSION "\n" ); iscsit_global =kzalloc (sizeof (*iscsit_global),GFP_KERNEL );if (!iscsit_global) -return -1 ; +return -ENOMEM ;spin_lock_init (&iscsit_global->ts_bitmap_lock);mutex_init (&auth_id_lock);
Signature · 1 line
2.20.1.7.g153144c
Quoted 17 lines · Jiapeng Chong
The driver is using -1 instead of the
-ENOMEMdefined macro to specify that a buffer allocation failed.
drivers/target/iscsi/iscsi_target.c:691iscsi_target_init_module()warn: returning -1 instead of-ENOMEMis sloppy.Reported-by Abaci Robot <[email protected]>Signed-off-by Jiapeng Chong <[email protected]>--- drivers/target/iscsi/iscsi_target.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/target/iscsi/iscsi_target.c +0
-0
drivers/target/iscsi/iscsi_target.c static int __init iscsi_target_init_module(void) · line 694
Quoted 8 lines
drivers/target/iscsi/iscsi_target.c +1
-1@@ -688,7 +688,7 @@ static int __init iscsi_target_init_module(void)pr_debug ("iSCSI-Target " ISCSIT_VERSION "\n" ); iscsit_global =kzalloc (sizeof (*iscsit_global),GFP_KERNEL );if (!iscsit_global) -return -1 ; +return -ENOMEM ;spin_lock_init (&iscsit_global->ts_bitmap_lock);mutex_init (&auth_id_lock);
you can also just use goto out, it has return -ENOMEM, no biggy.. Also, it will be useful to print the error message here as we are making this change..
irrespective of that :
Looks good.
-ck
Quoted 24 lines · Chaitanya Kulkarni
Quoted 23 lines · Jiapeng Chong
The driver is using -1 instead of the
-ENOMEMdefined macro to specify that a buffer allocation failed.
drivers/target/iscsi/iscsi_target.c:691iscsi_target_init_module()warn: returning -1 instead of-ENOMEMis sloppy.Reported-by Abaci Robot <[email protected]>Signed-off-by Jiapeng Chong <[email protected]>--- drivers/target/iscsi/iscsi_target.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/target/iscsi/iscsi_target.c +1
-1@@ -688,7 +688,7 @@ static int __init iscsi_target_init_module(void)pr_debug ("iSCSI-Target " ISCSIT_VERSION "\n" ); iscsit_global =kzalloc (sizeof (*iscsit_global),GFP_KERNEL );if (!iscsit_global) -return -1 ; +return -ENOMEM ;
Quoted 6 lines
drivers/target/iscsi/iscsi_target.c static int __init iscsi_target_init_module(void) · line 694
Quoted 2 lines
drivers/target/iscsi/iscsi_target.c +0
-0spin_lock_init (&iscsit_global->ts_bitmap_lock);mutex_init (&auth_id_lock);you can also just use goto out, it has return
-ENOMEM, no biggy.. Also, it will be useful to print the error message here as we are making this change..
Printing an error message for allocation failures is frowned upon. Checkpatch will complain.
Signature · 2 lines
Damien Le Moal Western Digital Research