Skip to content

Commit 6e58fc1

Browse files
Jia-Ye Ligregkh
authored andcommitted
staging: exfat: Use kvzalloc() instead of kzalloc() for exfat_sb_info
Fix mount failed "Cannot allocate memory". When the memory gets fragmented, kzalloc() might fail to allocate physically contiguous pages for the struct exfat_sb_info (its size is about 34KiB) even the total free memory is enough. Use kvzalloc() to solve this problem. Reviewed-by: Ethan Wu <[email protected]> Signed-off-by: Jia-Ye Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 5bdea60 commit 6e58fc1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/staging/exfat/exfat_super.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <linux/init.h>
88
#include <linux/time.h>
99
#include <linux/slab.h>
10+
#include <linux/mm.h>
1011
#include <linux/seq_file.h>
1112
#include <linux/pagemap.h>
1213
#include <linux/mpage.h>
@@ -3450,7 +3451,7 @@ static void exfat_free_super(struct exfat_sb_info *sbi)
34503451
kfree(sbi->options.iocharset);
34513452
/* mutex_init is in exfat_fill_super function. only for 3.7+ */
34523453
mutex_destroy(&sbi->s_lock);
3453-
kfree(sbi);
3454+
kvfree(sbi);
34543455
}
34553456

34563457
static void exfat_put_super(struct super_block *sb)
@@ -3845,7 +3846,7 @@ static int exfat_fill_super(struct super_block *sb, void *data, int silent)
38453846
* the filesystem, since we're only just about to mount
38463847
* it and have no inodes etc active!
38473848
*/
3848-
sbi = kzalloc(sizeof(struct exfat_sb_info), GFP_KERNEL);
3849+
sbi = kvzalloc(sizeof(*sbi), GFP_KERNEL);
38493850
if (!sbi)
38503851
return -ENOMEM;
38513852
mutex_init(&sbi->s_lock);

0 commit comments

Comments
 (0)