[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230626123252.73dbc139@endymion.delvare>
Date:   Mon, 26 Jun 2023 12:32:52 +0200
From:   Jean Delvare <jdelvare@...e.de>
To:     Luis Chamberlain <mcgrof@...nel.org>
Cc:     Michal Hocko <mhocko@...e.com>, linux-modules@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: [PATCH] module: print module name on refcount error
If module_put() triggers a refcount error, include the culprit
module name in the warning message, to easy further investigation of
the issue.
Signed-off-by: Jean Delvare <jdelvare@...e.de>
Suggested-by: Michal Hocko <mhocko@...e.com>
Cc: Luis Chamberlain <mcgrof@...nel.org>
---
 kernel/module/main.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
--- linux-6.3.orig/kernel/module/main.c
+++ linux-6.3/kernel/module/main.c
@@ -850,7 +850,9 @@ void module_put(struct module *module)
 	if (module) {
 		preempt_disable();
 		ret = atomic_dec_if_positive(&module->refcnt);
-		WARN_ON(ret < 0);	/* Failed to put refcount */
+		WARN(ret < 0,
+		     KERN_WARNING "Failed to put refcount for module %s\n",
+		     module->name);
 		trace_module_put(module, _RET_IP_);
 		preempt_enable();
 	}
-- 
Jean Delvare
SUSE L3 Support
Powered by blists - more mailing lists