From 1bf9609327fee700be63dac937726314eab3c1e8 Mon Sep 17 00:00:00 2001 From: Rik van Riel Date: Wed, 18 May 2022 14:17:05 -0400 Subject: [PATCH] kpatch: also unload a loaded, but no longer enabled kernel live patch Currently "kpatch force unload " will fail to unload an old kernel live patch module that is no longer seeing any use, when the "enabled" file for that module is no longer present. Check for the presence of such modules by checking /sys/module, and return success from disable_patch() for a module that is already disabled. This allows "kpatch force unload " to succeed for already disabled modules. Signed-off-by: Rik van Riel --- kpatch/kpatch | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kpatch/kpatch b/kpatch/kpatch index f4eb516..8ceae9b 100755 --- a/kpatch/kpatch +++ b/kpatch/kpatch @@ -378,8 +378,12 @@ disable_patch () { local enabled="$SYSFS/$modname/enabled" if ! [[ -e "$enabled" ]]; then - warn "patch module $modname is not loaded" - return 1 + if [[ -d "/sys/module/$modname" ]] ; then + # Module is loaded, but already disabled + return 0 + fi + warn "patch module $modname is not loaded" + return 1 fi if [[ "$(cat "$enabled")" -eq 1 ]]; then