[PATCH 18/29] tree wide: use kvfree() than conditional kfree()/vfree()
Sebastian Huber
sebastian.huber at embedded-brains.de
Thu Jul 5 07:49:38 UTC 2018
From: Tetsuo Handa <penguin-kernel at i-love.sakura.ne.jp>
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 <penguin-kernel at I-love.SAKURA.ne.jp>
Acked-by: Michal Hocko <mhocko at suse.com>
Acked-by: Jan Kara <jack at suse.com>
Acked-by: Russell King <rmk+kernel at arm.linux.org.uk>
Reviewed-by: Andreas Dilger <andreas.dilger at intel.com>
Acked-by: "Rafael J. Wysocki" <rjw at rjwysocki.net>
Acked-by: David Rientjes <rientjes at google.com>
Cc: "Luck, Tony" <tony.luck at intel.com>
Cc: Oleg Drokin <oleg.drokin at intel.com>
Cc: Boris Petkov <bp at suse.de>
Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
0 0 cpukit/libfs/src/jffs2/include/linux/mm.h
1 0 cpukit/libfs/src/jffs2/include/linux/slab.h
2 6 cpukit/libfs/src/jffs2/src/build.c
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 <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/mtd/mtd.h>
+#include <linux/mm.h> /* 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;
}
--
2.13.7
More information about the devel
mailing list