scst: Use kcalloc() instead of kzalloc() with multiply

git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6625 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2015-11-09 17:29:20 +00:00
parent 51acfdb0ac
commit a6ff47ce0a
2 changed files with 4 additions and 3 deletions

View File

@@ -3244,7 +3244,7 @@ int scst_cm_parse_descriptors(struct scst_cmd *ec_cmd)
TRACE_DBG("tgt_cnt %d", tgt_cnt);
tgt_descrs = kzalloc(sizeof(*tgt_descrs) * tgt_cnt, GFP_KERNEL);
tgt_descrs = kcalloc(tgt_cnt, sizeof(*tgt_descrs), GFP_KERNEL);
if (tgt_descrs == NULL) {
TRACE(TRACE_OUT_OF_MEM, "Unable to allocate tgt_descrs "
"(count %d, size %zd)", tgt_cnt,

View File

@@ -6121,7 +6121,8 @@ static int scst_ws_sg_tails_get(struct scst_data_descriptor *where, struct scst_
while (where[i].sdd_blocks != 0)
i++;
wsp->ws_sg_tails = kzalloc(sizeof(*(wsp->ws_sg_tails))*(i+1), GFP_KERNEL);
wsp->ws_sg_tails = kcalloc(i + 1, sizeof(*wsp->ws_sg_tails),
GFP_KERNEL);
if (wsp->ws_sg_tails == NULL) {
PRINT_ERROR("Unable to allocate ws_sg_tails (size %zd)",
sizeof(*wsp->ws_sg_tails)*i);
@@ -13636,7 +13637,7 @@ static int scst_parse_unmap_descriptors(struct scst_cmd *cmd)
if (cnt == 0)
goto out_put;
pd = kzalloc(sizeof(*pd) * cnt, GFP_KERNEL);
pd = kcalloc(cnt, sizeof(*pd), GFP_KERNEL);
if (pd == NULL) {
PRINT_ERROR("Unable to kmalloc UNMAP %d descriptors", cnt+1);
scst_set_busy(cmd);