kmalloc_array manages count*sizeof overflow.

Cc: Artem Bityutskiy <[email protected]>
Cc: Adrian Hunter <[email protected]>
Signed-off-by: Fabian Frederick <[email protected]>
---
 fs/ubifs/tnc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ubifs/tnc.c b/fs/ubifs/tnc.c
index 8a40cf9..2ed76c2 100644
--- a/fs/ubifs/tnc.c
+++ b/fs/ubifs/tnc.c
@@ -1087,8 +1087,8 @@ static struct ubifs_znode *dirty_cow_bottom_up(struct 
ubifs_info *c,
        ubifs_assert(znode);
        if (c->zroot.znode->level > BOTTOM_UP_HEIGHT) {
                kfree(c->bottom_up_buf);
-               c->bottom_up_buf = kmalloc(c->zroot.znode->level * sizeof(int),
-                                          GFP_NOFS);
+               c->bottom_up_buf = kmalloc_array(c->zroot.znode->level,
+                                                sizeof(int), GFP_NOFS);
                if (!c->bottom_up_buf)
                        return ERR_PTR(-ENOMEM);
                path = c->bottom_up_buf;
-- 
1.8.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
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