When enabling or disabling the live patch which is already in enabled or disabled state, the /sys/kernel/livepatch/<patch>/enabled will just return -EINVAL error value, so in user space will complaint like: "bash: echo: write error: Invalid argument" and this will confuse users. This patch just check the current state and the state changing to, if they are the same just do nothing and return okay. Signed-off-by: Xiubo Li <lixiubo@xxxxxxxxxxxxxxxxxxxx> --- kernel/livepatch/core.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c index 782172f..1f6942e 100644 --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c @@ -615,18 +615,12 @@ static ssize_t enabled_store(struct kobject *kobj, struct kobj_attribute *attr, mutex_lock(&klp_mutex); - if (val == patch->state) { - /* already in requested state */ - ret = -EINVAL; - goto err; - } - - if (val == KLP_ENABLED) { - ret = __klp_enable_patch(patch); - if (ret) - goto err; - } else { - ret = __klp_disable_patch(patch); + /* only not in requested state */ + if (val != patch->state) { + if (val == KLP_ENABLED) + ret = __klp_enable_patch(patch); + else + ret = __klp_disable_patch(patch); if (ret) goto err; } -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe live-patching" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html