[PATCH V2 0/2] kobject: avoid to cleanup kobject after module is unloaded

From: Ming Lei
Date: Sun Nov 28 2021 - 22:47:31 EST


Hello,

The 1st patch improves CONFIG_DEBUG_KOBJECT_RELEASE, so that kobject
cleanup after unloading module can be triggered easily. With this patch,
'modprobe kset-example' can trigger the issue very quickly.

The 2nd patch fixes the issue of cleaning up object after module is
unloaded, since kobj->ktype and related callbacks are often allocated
as module static variable. We need to make sure kobject is really
cleaned up before freeing module. This issue is reported by Petr Mladek.

V2:
- add comment on 1st patch, suggested by Greg, 1/2
- fix build failure in case that CONFIG_MODULE is disabled, and add
comment in kobj_module_callback(), 2/2


Ming Lei (2):
kobject: don't delay to cleanup module kobject
kobject: wait until kobject is cleaned up before freeing module

include/linux/kobject.h | 1 +
lib/kobject.c | 82 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 83 insertions(+)

--
2.31.1