Skip to content

Commit 82a819e

Browse files
luisbgNicholas Bellinger
authored and
Nicholas Bellinger
committed
iscsi-target: return -ENOMEM instead of -1 in case of failed kmalloc()
Smatch complains about returning hard coded error codes, silence this warning. drivers/target/iscsi/iscsi_target_parameters.c:211 iscsi_create_default_params() warn: returning -1 instead of -ENOMEM is sloppy Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com> Reviewed-by: Sagi Grimberg <sagig@mellanox.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
1 parent 6ba4bd2 commit 82a819e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/target/iscsi/iscsi_target_parameters.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ int iscsi_create_default_params(struct iscsi_param_list **param_list_ptr)
208208
if (!pl) {
209209
pr_err("Unable to allocate memory for"
210210
" struct iscsi_param_list.\n");
211-
return -1 ;
211+
return -ENOMEM;
212212
}
213213
INIT_LIST_HEAD(&pl->param_list);
214214
INIT_LIST_HEAD(&pl->extra_response_list);
@@ -578,7 +578,7 @@ int iscsi_copy_param_list(
578578
param_list = kzalloc(sizeof(struct iscsi_param_list), GFP_KERNEL);
579579
if (!param_list) {
580580
pr_err("Unable to allocate memory for struct iscsi_param_list.\n");
581-
return -1;
581+
return -ENOMEM;
582582
}
583583
INIT_LIST_HEAD(&param_list->param_list);
584584
INIT_LIST_HEAD(&param_list->extra_response_list);
@@ -629,7 +629,7 @@ int iscsi_copy_param_list(
629629

630630
err_out:
631631
iscsi_release_param_list(param_list);
632-
return -1;
632+
return -ENOMEM;
633633
}
634634

635635
static void iscsi_release_extra_responses(struct iscsi_param_list *param_list)
@@ -729,7 +729,7 @@ static int iscsi_add_notunderstood_response(
729729
if (!extra_response) {
730730
pr_err("Unable to allocate memory for"
731731
" struct iscsi_extra_response.\n");
732-
return -1;
732+
return -ENOMEM;
733733
}
734734
INIT_LIST_HEAD(&extra_response->er_list);
735735

@@ -1370,7 +1370,7 @@ int iscsi_decode_text_input(
13701370
tmpbuf = kzalloc(length + 1, GFP_KERNEL);
13711371
if (!tmpbuf) {
13721372
pr_err("Unable to allocate %u + 1 bytes for tmpbuf.\n", length);
1373-
return -1;
1373+
return -ENOMEM;
13741374
}
13751375

13761376
memcpy(tmpbuf, textbuf, length);

0 commit comments

Comments
 (0)