From 6ee8803978a96966f72eb54f376527887e8ddd28 Mon Sep 17 00:00:00 2001 From: Josh Poimboeuf Date: Fri, 2 May 2014 22:59:20 -0500 Subject: [PATCH] kmod/core: kpatch_unregister return error if !kpmod->enabled It's probably cleaner to just return -EINVAL if the kpmod isn't enabled, instead of warning and continuing, which would be dangerous. I think the reason I had it WARN before is because this condition shouldn't be possible given the source for the patch module. But the core module can't necessarily assume that it's our trustworthy patch module code on the other side. --- kmod/core/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kmod/core/core.c b/kmod/core/core.c index 9c39127..995ac62 100644 --- a/kmod/core/core.c +++ b/kmod/core/core.c @@ -543,7 +543,8 @@ int kpatch_unregister(struct kpatch_module *kpmod) int num_funcs = kpmod->num_funcs; int i, ret; - WARN_ON(!kpmod->enabled); + if (!kpmod->enabled) + return -EINVAL; down(&kpatch_mutex);