diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2012-04-17 02:33:59 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2012-05-06 18:02:33 -0400 |
commit | 381e309a658feadb48c14566b3b26ccb7eec75a0 (patch) | |
tree | bebfccfbb0353296a9b2d5c3f8e563341296d0e9 /drivers/target/iscsi | |
parent | bfb79eac2026b411df9e253a9c350039b4b04bb7 (diff) |
target/iscsi: cleanup some allocation style issues
We can use kcalloc() here instead of kzalloc(). It's better style and
it has overflow checking built in.
Also -ENOMEM is the correct error code for allocation errors. -1 means
-EPERM. None of the callers preserve the error codes so it doesn't
matter except as a cleanup.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target/iscsi')
-rw-r--r-- | drivers/target/iscsi/iscsi_target_seq_pdu_list.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/target/iscsi/iscsi_target_seq_pdu_list.c b/drivers/target/iscsi/iscsi_target_seq_pdu_list.c index 7d0effad9396..85a306e067ba 100644 --- a/drivers/target/iscsi/iscsi_target_seq_pdu_list.c +++ b/drivers/target/iscsi/iscsi_target_seq_pdu_list.c | |||
@@ -141,11 +141,11 @@ redo: | |||
141 | seq_count++; | 141 | seq_count++; |
142 | continue; | 142 | continue; |
143 | } | 143 | } |
144 | array = kzalloc(seq_count * sizeof(u32), GFP_KERNEL); | 144 | array = kcalloc(seq_count, sizeof(u32), GFP_KERNEL); |
145 | if (!array) { | 145 | if (!array) { |
146 | pr_err("Unable to allocate memory" | 146 | pr_err("Unable to allocate memory" |
147 | " for random array.\n"); | 147 | " for random array.\n"); |
148 | return -1; | 148 | return -ENOMEM; |
149 | } | 149 | } |
150 | iscsit_create_random_array(array, seq_count); | 150 | iscsit_create_random_array(array, seq_count); |
151 | 151 | ||
@@ -161,11 +161,11 @@ redo: | |||
161 | } | 161 | } |
162 | 162 | ||
163 | if (seq_count) { | 163 | if (seq_count) { |
164 | array = kzalloc(seq_count * sizeof(u32), GFP_KERNEL); | 164 | array = kcalloc(seq_count, sizeof(u32), GFP_KERNEL); |
165 | if (!array) { | 165 | if (!array) { |
166 | pr_err("Unable to allocate memory for" | 166 | pr_err("Unable to allocate memory for" |
167 | " random array.\n"); | 167 | " random array.\n"); |
168 | return -1; | 168 | return -ENOMEM; |
169 | } | 169 | } |
170 | iscsit_create_random_array(array, seq_count); | 170 | iscsit_create_random_array(array, seq_count); |
171 | 171 | ||
@@ -193,10 +193,10 @@ static int iscsit_randomize_seq_lists( | |||
193 | if (!seq_count) | 193 | if (!seq_count) |
194 | return 0; | 194 | return 0; |
195 | 195 | ||
196 | array = kzalloc(seq_count * sizeof(u32), GFP_KERNEL); | 196 | array = kcalloc(seq_count, sizeof(u32), GFP_KERNEL); |
197 | if (!array) { | 197 | if (!array) { |
198 | pr_err("Unable to allocate memory for random array.\n"); | 198 | pr_err("Unable to allocate memory for random array.\n"); |
199 | return -1; | 199 | return -ENOMEM; |
200 | } | 200 | } |
201 | iscsit_create_random_array(array, seq_count); | 201 | iscsit_create_random_array(array, seq_count); |
202 | 202 | ||
@@ -546,21 +546,21 @@ int iscsit_build_pdu_and_seq_lists( | |||
546 | iscsit_determine_counts_for_list(cmd, &bl, &seq_count, &pdu_count); | 546 | iscsit_determine_counts_for_list(cmd, &bl, &seq_count, &pdu_count); |
547 | 547 | ||
548 | if (!conn->sess->sess_ops->DataSequenceInOrder) { | 548 | if (!conn->sess->sess_ops->DataSequenceInOrder) { |
549 | seq = kzalloc(seq_count * sizeof(struct iscsi_seq), GFP_ATOMIC); | 549 | seq = kcalloc(seq_count, sizeof(struct iscsi_seq), GFP_ATOMIC); |
550 | if (!seq) { | 550 | if (!seq) { |
551 | pr_err("Unable to allocate struct iscsi_seq list\n"); | 551 | pr_err("Unable to allocate struct iscsi_seq list\n"); |
552 | return -1; | 552 | return -ENOMEM; |
553 | } | 553 | } |
554 | cmd->seq_list = seq; | 554 | cmd->seq_list = seq; |
555 | cmd->seq_count = seq_count; | 555 | cmd->seq_count = seq_count; |
556 | } | 556 | } |
557 | 557 | ||
558 | if (!conn->sess->sess_ops->DataPDUInOrder) { | 558 | if (!conn->sess->sess_ops->DataPDUInOrder) { |
559 | pdu = kzalloc(pdu_count * sizeof(struct iscsi_pdu), GFP_ATOMIC); | 559 | pdu = kcalloc(pdu_count, sizeof(struct iscsi_pdu), GFP_ATOMIC); |
560 | if (!pdu) { | 560 | if (!pdu) { |
561 | pr_err("Unable to allocate struct iscsi_pdu list.\n"); | 561 | pr_err("Unable to allocate struct iscsi_pdu list.\n"); |
562 | kfree(seq); | 562 | kfree(seq); |
563 | return -1; | 563 | return -ENOMEM; |
564 | } | 564 | } |
565 | cmd->pdu_list = pdu; | 565 | cmd->pdu_list = pdu; |
566 | cmd->pdu_count = pdu_count; | 566 | cmd->pdu_count = pdu_count; |