Re: [PATCH v7 0/8] devm_led_classdev_register() usage problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Lee

On 4/11/24 16:45, Lee Jones wrote:
On Fri, 29 Mar 2024, George Stark wrote:

Hello Lee

On 3/22/24 13:43, Lee Jones wrote:
On Fri, 22 Mar 2024, George Stark wrote:

Hello Lee

On 3/21/24 21:11, Lee Jones wrote:
On Thu, 14 Mar 2024, George Stark wrote:

This patch series fixes the problem of devm_led_classdev_register misusing.

The basic problem is described in [1]. Shortly when devm_led_classdev_register()
is used then led_classdev_unregister() called after driver's remove() callback.
led_classdev_unregister() calls driver's brightness_set callback and that callback
may use resources which were destroyed already in driver's remove().

After discussion with maintainers [2] [3] we decided:
1) don't touch led subsystem core code and don't remove led_set_brightness() from it
but fix drivers
2) don't use devm_led_classdev_unregister

So the solution is to use devm wrappers for all resources
driver's brightness_set() depends on. And introduce dedicated devm wrapper
for mutex as it's often used resource.

...

     locking/mutex: introduce devm_mutex_init()
     leds: aw2013: use devm API to cleanup module's resources
     leds: aw200xx: use devm API to cleanup module's resources
     leds: lp3952: use devm API to cleanup module's resources
     leds: lm3532: use devm API to cleanup module's resources
     leds: nic78bx: use devm API to cleanup module's resources
     leds: mlxreg: use devm_mutex_init() for mutex initialization
     leds: an30259a: use devm_mutex_init() for mutex initialization

    drivers/leds/leds-an30259a.c | 14 ++++----------
    drivers/leds/leds-aw200xx.c  | 32 +++++++++++++++++++++-----------
    drivers/leds/leds-aw2013.c   | 25 +++++++++++++------------
    drivers/leds/leds-lm3532.c   | 29 +++++++++++++++++------------
    drivers/leds/leds-lp3952.c   | 21 +++++++++++----------
    drivers/leds/leds-mlxreg.c   | 14 +++++---------
    drivers/leds/leds-nic78bx.c  | 23 +++++++++++++----------
    include/linux/mutex.h        | 27 +++++++++++++++++++++++++++
    kernel/locking/mutex-debug.c | 11 +++++++++++
    9 files changed, 122 insertions(+), 74 deletions(-)

Doesn't apply to v6.8.

What base was used for this?

I've just pulled git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
and v7 was applied cleanly. linux-next is ok too.

v6.8 is lack of recent patch 6969d0a2ba1adc9ba6a49b9805f24080896c255c
v7's patch #2 depends on it

No problem.  I'll wait for v6.9-rc1.


Just checked the v7 patch series on released 6.9-rc1 and it's applied
cleanly. If anything i can help please let me know.

It applies, but doesn't seem to build:

make --silent --keep-going --jobs=8 O=../build ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- CROSS_COMPILE_COMPAT=arm-linux-gnueabihf- 'CC=sccache aarch64-linux-gnu-gcc' 'HOSTCC=sccache gcc' allmodconfig
make --silent --keep-going --jobs=8 O=../build ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- CROSS_COMPILE_COMPAT=arm-linux-gnueabihf- 'CC=sccache aarch64-linux-gnu-gcc' 'HOSTCC=sccache gcc'
ERROR: modpost: "__devm_mutex_init" [drivers/leds/leds-an30259a.ko] undefined!
ERROR: modpost: "__devm_mutex_init" [drivers/leds/leds-aw200xx.ko] undefined!
ERROR: modpost: "__devm_mutex_init" [drivers/leds/leds-aw2013.ko] undefined!
ERROR: modpost: "__devm_mutex_init" [drivers/leds/leds-lm3532.ko] undefined!
ERROR: modpost: "__devm_mutex_init" [drivers/leds/leds-mlxreg.ko] undefined!
make[3]: *** [/builds/linux/scripts/Makefile.modpost:145: Module.symvers] Error 1

Did you forget to export it?


Yes, my bad. I tested *DEBUG* configs but without modules enabled.
Adding EXPORT_SYMBOL_GPL(__devm_mutex_init); fixes the problem,
v8 is on the way.

--
Best regards
George




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux