From 195c52bdd5d5ecfdabf5a7c6159efe299e534f84 Mon Sep 17 00:00:00 2001 From: Kari Argillander Date: Tue, 24 Aug 2021 21:37:07 +0300 Subject: 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 Signed-off-by: Kari Argillander Signed-off-by: Konstantin Komarov --- fs/ntfs3/attrlist.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'fs/ntfs3/attrlist.c') diff --git a/fs/ntfs3/attrlist.c b/fs/ntfs3/attrlist.c index ea561361b576..348bfb54db09 100644 --- a/fs/ntfs3/attrlist.c +++ b/fs/ntfs3/attrlist.c @@ -28,7 +28,7 @@ static inline bool al_is_valid_le(const struct ntfs_inode *ni, void al_destroy(struct ntfs_inode *ni) { run_close(&ni->attr_list.run); - ntfs_free(ni->attr_list.le); + kfree(ni->attr_list.le); ni->attr_list.le = NULL; ni->attr_list.size = 0; ni->attr_list.dirty = false; @@ -51,7 +51,7 @@ int ntfs_load_attr_list(struct ntfs_inode *ni, struct ATTRIB *attr) if (!attr->non_res) { lsize = le32_to_cpu(attr->res.data_size); - le = ntfs_malloc(al_aligned(lsize)); + le = kmalloc(al_aligned(lsize), GFP_NOFS); if (!le) { err = -ENOMEM; goto out; @@ -74,7 +74,7 @@ int ntfs_load_attr_list(struct ntfs_inode *ni, struct ATTRIB *attr) if (err < 0) goto out; - le = ntfs_malloc(al_aligned(lsize)); + le = kmalloc(al_aligned(lsize), GFP_NOFS); if (!le) { err = -ENOMEM; goto out; @@ -289,7 +289,7 @@ int al_add_le(struct ntfs_inode *ni, enum ATTR_TYPE type, const __le16 *name, off = PtrOffset(al->le, le); if (new_size > asize) { - void *ptr = ntfs_malloc(new_asize); + void *ptr = kmalloc(new_asize, GFP_NOFS); if (!ptr) return -ENOMEM; @@ -297,7 +297,7 @@ int al_add_le(struct ntfs_inode *ni, enum ATTR_TYPE type, const __le16 *name, memcpy(ptr, al->le, off); memcpy(Add2Ptr(ptr, off + sz), le, al->size - off); le = Add2Ptr(ptr, off); - ntfs_free(al->le); + kfree(al->le); al->le = ptr; } else { memmove(Add2Ptr(le, sz), le, al->size - off); -- cgit v1.2.3-58-ga151