OSDN Git Service

ubifs: Use kmalloc_array()
authorRichard Weinberger <richard@nod.at>
Mon, 2 Jul 2018 21:47:13 +0000 (23:47 +0200)
committerRichard Weinberger <richard@nod.at>
Tue, 14 Aug 2018 22:25:20 +0000 (00:25 +0200)
Since commit 6da2ec56059c ("treewide: kmalloc() -> kmalloc_array()")
we use kmalloc_array() for kmalloc() that computes the length with
a multiplication.

Cc: Kees Cook <keescook@chromium.org>
Suggested-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Richard Weinberger <richard@nod.at>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Richard Weinberger <richard@nod.at>
fs/ubifs/journal.c

index cef0d76..42ba4ce 100644 (file)
@@ -1291,7 +1291,7 @@ static int truncate_data_node(const struct ubifs_info *c, const struct inode *in
        int err, dlen, compr_type, out_len, old_dlen;
 
        out_len = le32_to_cpu(dn->size);
-       buf = kmalloc(out_len * WORST_COMPR_FACTOR, GFP_NOFS);
+       buf = kmalloc_array(out_len, WORST_COMPR_FACTOR, GFP_NOFS);
        if (!buf)
                return -ENOMEM;