[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20171219132844.28354-2-mhocko@kernel.org>
Date: Tue, 19 Dec 2017 14:28:43 +0100
From: Michal Hocko <mhocko@...nel.org>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Al Viro <viro@...iv.linux.org.uk>,
Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>,
Aliaksei Karaliou <akaraliou.dev@...il.com>,
<linux-mm@...ck.org>, <linux-fsdevel@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>,
Glauber Costa <glauber@...lladb.com>,
Michal Hocko <mhocko@...e.com>
Subject: [PATCH 1/2] mm,vmscan: Make unregister_shrinker() no-op if register_shrinker() failed.
From: Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>
Since allowing register_shrinker() callers to call unregister_shrinker()
when register_shrinker() failed can simplify error recovery path, this
patch makes unregister_shrinker() no-op when register_shrinker() failed.
Let's also make sure that double unregister_shrinker doesn't blow up as
well and NULL nr_deferred on successful de-registration to make the
clean up even simpler and prevent from potential memory corruptions.
[akaraliou.dev@...il.com: set nr_deferred = NULL to handle double
unregister]
Signed-off-by: Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>
Reported-by: syzbot <syzkaller@...glegroups.com>
Cc: Glauber Costa <glauber@...lladb.com>
Cc: Al Viro <viro@...iv.linux.org.uk>
Signed-off-by: Michal Hocko <mhocko@...e.com>
---
mm/vmscan.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 80dea50f421b..7a5801040fd4 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -281,10 +281,13 @@ EXPORT_SYMBOL(register_shrinker);
*/
void unregister_shrinker(struct shrinker *shrinker)
{
+ if (!shrinker->nr_deferred)
+ return;
down_write(&shrinker_rwsem);
list_del(&shrinker->list);
up_write(&shrinker_rwsem);
kfree(shrinker->nr_deferred);
+ shrinker->nr_deferred = NULL;
}
EXPORT_SYMBOL(unregister_shrinker);
--
2.15.1
Powered by blists - more mailing lists