From c9670dd1bc38e2930c041e0ae1117057060ec615 Mon Sep 17 00:00:00 2001 From: Tetsuo Handa Date: Fri, 22 Jan 2016 15:11:02 -0800 Subject: tree wide: use kvfree() than conditional kfree()/vfree() There are many locations that do if (memory_was_allocated_by_vmalloc) vfree(ptr); else kfree(ptr); but kvfree() can handle both kmalloc()ed memory and vmalloc()ed memory using is_vmalloc_addr(). Unless callers have special reasons, we can replace this branch with kvfree(). Please check and reply if you found problems. Signed-off-by: Tetsuo Handa Acked-by: Michal Hocko Acked-by: Jan Kara Acked-by: Russell King Reviewed-by: Andreas Dilger Acked-by: "Rafael J. Wysocki" Acked-by: David Rientjes Cc: "Luck, Tony" Cc: Oleg Drokin Cc: Boris Petkov Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- cpukit/libfs/src/jffs2/include/linux/mm.h | 0 cpukit/libfs/src/jffs2/include/linux/slab.h | 1 + cpukit/libfs/src/jffs2/src/build.c | 8 ++------ 3 files changed, 3 insertions(+), 6 deletions(-) create mode 100644 cpukit/libfs/src/jffs2/include/linux/mm.h (limited to 'cpukit') diff --git a/cpukit/libfs/src/jffs2/include/linux/mm.h b/cpukit/libfs/src/jffs2/include/linux/mm.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/cpukit/libfs/src/jffs2/include/linux/slab.h b/cpukit/libfs/src/jffs2/include/linux/slab.h index 00ddbb274a..532586e210 100644 --- a/cpukit/libfs/src/jffs2/include/linux/slab.h +++ b/cpukit/libfs/src/jffs2/include/linux/slab.h @@ -8,6 +8,7 @@ #define kzalloc(x, y) calloc(1, x) #define kmalloc(x, y) malloc(x) #define kfree(x) free(x) +#define kvfree(x) free(x) #define vmalloc(x) malloc(x) #define vfree(x) free(x) diff --git a/cpukit/libfs/src/jffs2/src/build.c b/cpukit/libfs/src/jffs2/src/build.c index b16f2c9fe7..cbc424283c 100644 --- a/cpukit/libfs/src/jffs2/src/build.c +++ b/cpukit/libfs/src/jffs2/src/build.c @@ -19,6 +19,7 @@ #include #include #include +#include /* kvfree() */ #include "nodelist.h" static void jffs2_build_remove_unlinked_inode(struct jffs2_sb_info *, @@ -385,12 +386,7 @@ int jffs2_do_mount_fs(struct jffs2_sb_info *c) return 0; out_free: -#ifndef __ECOS - if (jffs2_blocks_use_vmalloc(c)) - vfree(c->blocks); - else -#endif - kfree(c->blocks); + kvfree(c->blocks); return ret; } -- cgit v1.2.3