kcalloc manages count*sizeof overflow.

Cc: Christine Caulfield <ccaul...@redhat.com>
Cc: David Teigland <teigl...@redhat.com>
Signed-off-by: Fabian Frederick <f...@skynet.be>
---
 fs/dlm/lock.c   | 2 +-
 fs/dlm/member.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c
index 83f3d55..3653dbe 100644
--- a/fs/dlm/lock.c
+++ b/fs/dlm/lock.c
@@ -1427,7 +1427,7 @@ void dlm_scan_waiters(struct dlm_ls *ls)
 
                if (!num_nodes) {
                        num_nodes = ls->ls_num_nodes;
-                       warned = kzalloc(num_nodes * sizeof(int), GFP_KERNEL);
+                       warned = kcalloc(num_nodes, sizeof(int), GFP_KERNEL);
                }
                if (!warned)
                        continue;
diff --git a/fs/dlm/member.c b/fs/dlm/member.c
index 9c47f1c..aa57ac3 100644
--- a/fs/dlm/member.c
+++ b/fs/dlm/member.c
@@ -218,7 +218,7 @@ int dlm_slots_assign(struct dlm_ls *ls, int *num_slots, int 
*slots_size,
 
        array_size = max + need;
 
-       array = kzalloc(array_size * sizeof(struct dlm_slot), GFP_NOFS);
+       array = kcalloc(array_size, sizeof(struct dlm_slot), GFP_NOFS);
        if (!array)
                return -ENOMEM;
 
@@ -493,7 +493,7 @@ void dlm_lsop_recover_done(struct dlm_ls *ls)
 
        num = ls->ls_num_nodes;
 
-       slots = kzalloc(num * sizeof(struct dlm_slot), GFP_KERNEL);
+       slots = kcalloc(num, sizeof(struct dlm_slot), GFP_KERNEL);
        if (!slots)
                return;
 
-- 
1.8.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to