summary refs log tree commit diff
path: root/fs/ntfs3/super.c
diff options
context:
space:
mode:
authorKari Argillander <kari.argillander@gmail.com>2021-08-24 21:37:07 +0300
committerKonstantin Komarov <almaz.alexandrovich@paragon-software.com>2021-08-27 17:05:12 +0300
commit195c52bdd5d5ecfdabf5a7c6159efe299e534f84 (patch)
tree19b4150df32241152b7b8233aa7099e1e7a794c5 /fs/ntfs3/super.c
parentfa3cacf544636b2dc48cfb2f277a2071f14d66a2 (diff)
downloadlinux-195c52bdd5d5ecfdabf5a7c6159efe299e534f84.tar.gz
fs/ntfs3: Do not use driver own alloc wrappers
Problem with these wrapper is that we cannot take off example GFP_NOFS
flag. It is not recomended use those in all places. Also if we change
one driver specific wrapper to kernel wrapper then it would look really
weird. People should be most familiar with kernel wrappers so let's just
use those ones.

Driver specific alloc wrapper also confuse some static analyzing tools,
good example is example kernels checkpatch tool. After we converter
these to kernel specific then warnings is showed.

Following Coccinelle script was used to automate changing.

virtual patch

@alloc depends on patch@
expression x;
expression y;
@@
(
-	ntfs_malloc(x)
+	kmalloc(x, GFP_NOFS)
|
-	ntfs_zalloc(x)
+	kzalloc(x, GFP_NOFS)
|
-	ntfs_vmalloc(x)
+	kvmalloc(x, GFP_NOFS)
|
-	ntfs_free(x)
+	kfree(x)
|
-	ntfs_vfree(x)
+	kvfree(x)
|
-	ntfs_memdup(x, y)
+	kmemdup(x, y, GFP_NOFS)
)

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kari Argillander <kari.argillander@gmail.com>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Diffstat (limited to 'fs/ntfs3/super.c')
-rw-r--r--fs/ntfs3/super.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index 7a501bca26d7..17ee715ab539 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -468,9 +468,9 @@ static void init_once(void *foo)
 /* noinline to reduce binary size*/
 static noinline void put_ntfs(struct ntfs_sb_info *sbi)
 {
-	ntfs_free(sbi->new_rec);
-	ntfs_vfree(ntfs_put_shared(sbi->upcase));
-	ntfs_free(sbi->def_table);
+	kfree(sbi->new_rec);
+	kvfree(ntfs_put_shared(sbi->upcase));
+	kfree(sbi->def_table);
 
 	wnd_close(&sbi->mft.bitmap);
 	wnd_close(&sbi->used.bitmap);
@@ -496,14 +496,14 @@ static noinline void put_ntfs(struct ntfs_sb_info *sbi)
 	indx_clear(&sbi->security.index_sdh);
 	indx_clear(&sbi->reparse.index_r);
 	indx_clear(&sbi->objid.index_o);
-	ntfs_free(sbi->compress.lznt);
+	kfree(sbi->compress.lznt);
 #ifdef CONFIG_NTFS3_LZX_XPRESS
 	xpress_free_decompressor(sbi->compress.xpress);
 	lzx_free_decompressor(sbi->compress.lzx);
 #endif
 	clear_mount_options(&sbi->options);
 
-	ntfs_free(sbi);
+	kfree(sbi);
 }
 
 static void ntfs_put_super(struct super_block *sb)
@@ -848,7 +848,7 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,
 
 	sbi->used.bitmap.nbits = clusters;
 
-	rec = ntfs_zalloc(record_size);
+	rec = kzalloc(record_size, GFP_NOFS);
 	if (!rec) {
 		err = -ENOMEM;
 		goto out;
@@ -915,7 +915,7 @@ static int ntfs_fill_super(struct super_block *sb, void *data, int silent)
 
 	ref.high = 0;
 
-	sbi = ntfs_zalloc(sizeof(struct ntfs_sb_info));
+	sbi = kzalloc(sizeof(struct ntfs_sb_info), GFP_NOFS);
 	if (!sbi)
 		return -ENOMEM;
 
@@ -1181,7 +1181,7 @@ static int ntfs_fill_super(struct super_block *sb, void *data, int silent)
 		goto out;
 	}
 	bytes = inode->i_size;
-	sbi->def_table = t = ntfs_malloc(bytes);
+	sbi->def_table = t = kmalloc(bytes, GFP_NOFS);
 	if (!t) {
 		err = -ENOMEM;
 		goto out;
@@ -1247,7 +1247,7 @@ static int ntfs_fill_super(struct super_block *sb, void *data, int silent)
 		goto out;
 	}
 
-	sbi->upcase = upcase = ntfs_vmalloc(0x10000 * sizeof(short));
+	sbi->upcase = upcase = kvmalloc(0x10000 * sizeof(short), GFP_KERNEL);
 	if (!upcase) {
 		err = -ENOMEM;
 		goto out;
@@ -1277,7 +1277,7 @@ static int ntfs_fill_super(struct super_block *sb, void *data, int silent)
 	shared = ntfs_set_shared(upcase, 0x10000 * sizeof(short));
 	if (shared && upcase != shared) {
 		sbi->upcase = shared;
-		ntfs_vfree(upcase);
+		kvfree(upcase);
 	}
 
 	iput(inode);