Whamcloud - gitweb
e2fsck/revoke.c: sync kernel's adoption of kmalloc_array()
authorTheodore Ts'o <tytso@mit.edu>
Sat, 9 Nov 2019 02:25:59 +0000 (21:25 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 9 Nov 2019 06:55:14 +0000 (01:55 -0500)
Sync the changes to e2fsck/revoke.c from commit 6da2ec56059c
("treewide: kmalloc() -> kmalloc_array()"), and add the emulation of
kmalloc_array() to e2fsck/jfs_user.h

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/jfs_user.h
e2fsck/revoke.c

index 239ac1d..1445c3e 100644 (file)
@@ -92,6 +92,13 @@ typedef struct {
 #define kmalloc(len, flags) malloc(len)
 #define kfree(p) free(p)
 
+static inline void *kmalloc_array(unsigned n, unsigned size, int flags)
+{
+       if (n && (~0U)/n < size)
+               return NULL;
+       return malloc(n * size);
+}
+
 #define cond_resched() do { } while (0)
 
 #define __init
index 3fadf57..3f78330 100644 (file)
@@ -228,7 +228,7 @@ static struct jbd2_revoke_table_s *jbd2_journal_init_revoke_table(int hash_size)
        table->hash_size = hash_size;
        table->hash_shift = shift;
        table->hash_table =
-               kmalloc(hash_size * sizeof(struct list_head), GFP_KERNEL);
+               kmalloc_array(hash_size, sizeof(struct list_head), GFP_KERNEL);
        if (!table->hash_table) {
                kmem_cache_free(jbd2_revoke_table_cache, table);
                table = NULL;