提交 2f48e061 编写于 作者: M Markus Elfring 提交者: David Teigland

dlm: Use kcalloc() in two functions

* Multiplications for the size determination of memory allocations
  indicated that array data structures should be processed.
  Thus reuse the corresponding function "kcalloc".

  This issue was detected by using the Coccinelle software.

* Replace the specification of data structures by pointer dereferences
  to make the corresponding size determinations a bit safer according to
  the Linux coding style convention.
Signed-off-by: NMarkus Elfring <elfring@users.sourceforge.net>
Signed-off-by: NDavid Teigland <teigland@redhat.com>
上级 790854be
...@@ -217,8 +217,7 @@ int dlm_slots_assign(struct dlm_ls *ls, int *num_slots, int *slots_size, ...@@ -217,8 +217,7 @@ int dlm_slots_assign(struct dlm_ls *ls, int *num_slots, int *slots_size,
} }
array_size = max + need; array_size = max + need;
array = kcalloc(array_size, sizeof(*array), GFP_NOFS);
array = kzalloc(array_size * sizeof(struct dlm_slot), GFP_NOFS);
if (!array) if (!array)
return -ENOMEM; return -ENOMEM;
...@@ -491,8 +490,7 @@ void dlm_lsop_recover_done(struct dlm_ls *ls) ...@@ -491,8 +490,7 @@ void dlm_lsop_recover_done(struct dlm_ls *ls)
return; return;
num = ls->ls_num_nodes; num = ls->ls_num_nodes;
slots = kcalloc(num, sizeof(*slots), GFP_KERNEL);
slots = kzalloc(num * sizeof(struct dlm_slot), GFP_KERNEL);
if (!slots) if (!slots)
return; return;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册