From: Michal Hocko <mhocko@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
Aliaksei Karaliou <akaraliou.dev@gmail.com>,
linux-mm@kvack.org, linux-fsdevel@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>,
Glauber Costa <glauber@scylladb.com>,
Michal Hocko <mhocko@suse.com>
Subject: [PATCH 1/2] mm,vmscan: Make unregister_shrinker() no-op if register_shrinker() failed.
Date: Tue, 19 Dec 2017 14:28:43 +0100 [thread overview]
Message-ID: <20171219132844.28354-2-mhocko@kernel.org> (raw)
In-Reply-To: <20171219132844.28354-1-mhocko@kernel.org>
From: Tetsuo Handa <penguin-kernel@I-love.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@gmail.com: set nr_deferred = NULL to handle double
unregister]
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Reported-by: syzbot <syzkaller@googlegroups.com>
Cc: Glauber Costa <glauber@scylladb.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Michal Hocko <mhocko@suse.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
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2017-12-19 13:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-19 13:28 [resend PATCH 0/2] fix VFS register_shrinker fixup Michal Hocko
2017-12-19 13:28 ` Michal Hocko [this message]
2017-12-19 13:28 ` [PATCH 2/2] VFS: handle register_shrinker failure in sget_userns Michal Hocko
2017-12-19 15:19 ` [resend PATCH 0/2] fix VFS register_shrinker fixup Michal Hocko
2017-12-19 15:34 ` Al Viro
2017-12-19 15:57 ` Michal Hocko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171219132844.28354-2-mhocko@kernel.org \
--to=mhocko@kernel.org \
--cc=akaraliou.dev@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=glauber@scylladb.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox