linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: check for sleepable context in kvfree
@ 2019-07-23 13:12 Jeff Layton
  2019-07-23 17:52 ` Jeff Layton
  0 siblings, 1 reply; 7+ messages in thread
From: Jeff Layton @ 2019-07-23 13:12 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel, viro, lhenriques, cmaiolino

A lot of callers of kvfree only go down the vfree path under very rare
circumstances, and so may never end up hitting the might_sleep_if in it.
Ensure that when kvfree is called, that it is operating in a context
where it is allowed to sleep.

Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Luis Henriques <lhenriques@suse.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 mm/util.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mm/util.c b/mm/util.c
index e6351a80f248..81ec2a003c86 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -482,6 +482,8 @@ EXPORT_SYMBOL(kvmalloc_node);
  */
 void kvfree(const void *addr)
 {
+	might_sleep_if(!in_interrupt());
+
 	if (is_vmalloc_addr(addr))
 		vfree(addr);
 	else
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-07-23 18:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-23 13:12 [PATCH] mm: check for sleepable context in kvfree Jeff Layton
2019-07-23 17:52 ` Jeff Layton
2019-07-23 17:55   ` Matthew Wilcox
2019-07-23 18:05     ` Jeff Layton
2019-07-23 18:11       ` Matthew Wilcox
2019-07-23 18:19         ` Jeff Layton
2019-07-23 18:29           ` Matthew Wilcox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).