aboutsummaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authorTetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>2016-01-22 18:11:02 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-01-22 20:02:18 -0500
commit1d5cfdb076288df5eb95545a547a39905e95c930 (patch)
treec644d2e609c3054833710b75ab1d0fe50fb17c01 /ipc
parenteab95db69d334745d3034072f4a7204084136c88 (diff)
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 <penguin-kernel@I-love.SAKURA.ne.jp> Acked-by: Michal Hocko <mhocko@suse.com> Acked-by: Jan Kara <jack@suse.com> Acked-by: Russell King <rmk+kernel@arm.linux.org.uk> Reviewed-by: Andreas Dilger <andreas.dilger@intel.com> Acked-by: "Rafael J. Wysocki" <rjw@rjwysocki.net> Acked-by: David Rientjes <rientjes@google.com> Cc: "Luck, Tony" <tony.luck@intel.com> Cc: Oleg Drokin <oleg.drokin@intel.com> Cc: Boris Petkov <bp@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'ipc')
-rw-r--r--ipc/sem.c2
-rw-r--r--ipc/util.c11
-rw-r--r--ipc/util.h2
3 files changed, 5 insertions, 10 deletions
diff --git a/ipc/sem.c b/ipc/sem.c
index b471e5a3863d..cddd5b5fde51 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -1493,7 +1493,7 @@ out_rcu_wakeup:
1493 wake_up_sem_queue_do(&tasks); 1493 wake_up_sem_queue_do(&tasks);
1494out_free: 1494out_free:
1495 if (sem_io != fast_sem_io) 1495 if (sem_io != fast_sem_io)
1496 ipc_free(sem_io, sizeof(ushort)*nsems); 1496 ipc_free(sem_io);
1497 return err; 1497 return err;
1498} 1498}
1499 1499
diff --git a/ipc/util.c b/ipc/util.c
index 0f401d94b7c6..798cad18dd87 100644
--- a/ipc/util.c
+++ b/ipc/util.c
@@ -414,17 +414,12 @@ void *ipc_alloc(int size)
414/** 414/**
415 * ipc_free - free ipc space 415 * ipc_free - free ipc space
416 * @ptr: pointer returned by ipc_alloc 416 * @ptr: pointer returned by ipc_alloc
417 * @size: size of block
418 * 417 *
419 * Free a block created with ipc_alloc(). The caller must know the size 418 * Free a block created with ipc_alloc().
420 * used in the allocation call.
421 */ 419 */
422void ipc_free(void *ptr, int size) 420void ipc_free(void *ptr)
423{ 421{
424 if (size > PAGE_SIZE) 422 kvfree(ptr);
425 vfree(ptr);
426 else
427 kfree(ptr);
428} 423}
429 424
430/** 425/**
diff --git a/ipc/util.h b/ipc/util.h
index 3a8a5a0eca62..51f7ca58ac67 100644
--- a/ipc/util.h
+++ b/ipc/util.h
@@ -118,7 +118,7 @@ int ipcperms(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, short flg);
118 * both function can sleep 118 * both function can sleep
119 */ 119 */
120void *ipc_alloc(int size); 120void *ipc_alloc(int size);
121void ipc_free(void *ptr, int size); 121void ipc_free(void *ptr);
122 122
123/* 123/*
124 * For allocation that need to be freed by RCU. 124 * For allocation that need to be freed by RCU.