Patch "exfat: use kvmalloc_array/kvfree instead of kmalloc_array/kfree" has been added to the 4.19-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    exfat: use kvmalloc_array/kvfree instead of kmalloc_array/kfree

to the 4.19-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     exfat-use-kvmalloc_array-kvfree-instead-of-kmalloc_a.patch
and it can be found in the queue-4.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 08e0003605d52d1c70788d8ca2a531cd4aff5a3f
Author: gaoming <gaoming20@xxxxxxxxxxx>
Date:   Wed Jul 5 15:15:15 2023 +0800

    exfat: use kvmalloc_array/kvfree instead of kmalloc_array/kfree
    
    [ Upstream commit daf60d6cca26e50d65dac374db92e58de745ad26 ]
    
    The call stack shown below is a scenario in the Linux 4.19 kernel.
    Allocating memory failed where exfat fs use kmalloc_array due to
    system memory fragmentation, while the u-disk was inserted without
    recognition.
    Devices such as u-disk using the exfat file system are pluggable and
    may be insert into the system at any time.
    However, long-term running systems cannot guarantee the continuity of
    physical memory. Therefore, it's necessary to address this issue.
    
    Binder:2632_6: page allocation failure: order:4,
     mode:0x6040c0(GFP_KERNEL|__GFP_COMP), nodemask=(null)
    Call trace:
    [242178.097582]  dump_backtrace+0x0/0x4
    [242178.097589]  dump_stack+0xf4/0x134
    [242178.097598]  warn_alloc+0xd8/0x144
    [242178.097603]  __alloc_pages_nodemask+0x1364/0x1384
    [242178.097608]  kmalloc_order+0x2c/0x510
    [242178.097612]  kmalloc_order_trace+0x40/0x16c
    [242178.097618]  __kmalloc+0x360/0x408
    [242178.097624]  load_alloc_bitmap+0x160/0x284
    [242178.097628]  exfat_fill_super+0xa3c/0xe7c
    [242178.097635]  mount_bdev+0x2e8/0x3a0
    [242178.097638]  exfat_fs_mount+0x40/0x50
    [242178.097643]  mount_fs+0x138/0x2e8
    [242178.097649]  vfs_kern_mount+0x90/0x270
    [242178.097655]  do_mount+0x798/0x173c
    [242178.097659]  ksys_mount+0x114/0x1ac
    [242178.097665]  __arm64_sys_mount+0x24/0x34
    [242178.097671]  el0_svc_common+0xb8/0x1b8
    [242178.097676]  el0_svc_handler+0x74/0x90
    [242178.097681]  el0_svc+0x8/0x340
    
    By analyzing the exfat code,we found that continuous physical memory
    is not required here,so kvmalloc_array is used can solve this problem.
    
    Cc: stable@xxxxxxxxxxxxxxx
    Signed-off-by: gaoming <gaoming20@xxxxxxxxxxx>
    Signed-off-by: Namjae Jeon <linkinjeon@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/exfat/balloc.c b/fs/exfat/balloc.c
index 6a04cc02565a1..322aa78c50fb4 100644
--- a/fs/exfat/balloc.c
+++ b/fs/exfat/balloc.c
@@ -70,7 +70,7 @@ static int exfat_allocate_bitmap(struct super_block *sb,
 	}
 	sbi->map_sectors = ((need_map_size - 1) >>
 			(sb->s_blocksize_bits)) + 1;
-	sbi->vol_amap = kmalloc_array(sbi->map_sectors,
+	sbi->vol_amap = kvmalloc_array(sbi->map_sectors,
 				sizeof(struct buffer_head *), GFP_KERNEL);
 	if (!sbi->vol_amap)
 		return -ENOMEM;
@@ -85,7 +85,7 @@ static int exfat_allocate_bitmap(struct super_block *sb,
 			while (j < i)
 				brelse(sbi->vol_amap[j++]);
 
-			kfree(sbi->vol_amap);
+			kvfree(sbi->vol_amap);
 			sbi->vol_amap = NULL;
 			return -EIO;
 		}
@@ -142,7 +142,7 @@ void exfat_free_bitmap(struct exfat_sb_info *sbi)
 	for (i = 0; i < sbi->map_sectors; i++)
 		__brelse(sbi->vol_amap[i]);
 
-	kfree(sbi->vol_amap);
+	kvfree(sbi->vol_amap);
 }
 
 /*



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux