1. 12 Jul, 2024 3 commits
  2. 11 Jul, 2024 2 commits
  3. 04 Jul, 2024 2 commits
  4. 27 Jun, 2024 1 commit
    • Luca Ceresoli's avatar
      Revert "leds: led-core: Fix refcount leak in of_led_get()" · 940b2716
      Luca Ceresoli authored
      This reverts commit da1afe8e.
      
      Commit 699a8c7c ("leds: Add of_led_get() and led_put()"), introduced in
      5.5, added of_led_get() and led_put() but missed a put_device() in
      led_put(), thus creating a leak in case the consumer device is removed.
      
      Arguably device removal was not very popular, so this went apparently
      unnoticed until 2022. In January 2023 two different patches got merged to
      fix the same bug:
      
       - commit da1afe8e ("leds: led-core: Fix refcount leak in of_led_get()")
       - commit 44511094 ("leds: led-class: Add missing put_device() to led_put()")
      
      They fix the bug in two different ways, which creates no patch conflicts,
      and both were merged in v6.2. The result is that now there is one more
      put_device() than get_device()s, instead of one less.
      
      Arguably device removal is not very popular yet, so this apparently hasn't
      been noticed as well up to now. But it blew up here while I'm working with
      device tree overlay insertion and removal. The symptom is an apparently
      unrelated list of oopses on device removal, with reasons:
      
        kernfs: can not remove 'uevent', no directory
        kernfs: can not remove 'brightness', no directory
        kernfs: can not remove 'max_brightness', no directory
        ...
      
      Here sysfs fails removing attribute files, which is because the device name
      changed and so the sysfs path. This is because the device name string got
      corrupted, which is because it got freed too early and its memory reused.
      
      Different symptoms could appear in different use cases.
      
      Fix by removing one of the two fixes.
      
      The choice was to remove commit da1afe8e because:
      
       * it is calling put_device() inside of_led_get() just after getting the
         device, thus it is basically not refcounting the LED device at all
         during its entire lifetime
       * it does not add a corresponding put_device() in led_get(), so it fixes
         only the OF case
      
      The other fix (44511094) is adding the put_device() in led_put() so it
      covers the entire lifetime, and it works even in the non-DT case.
      
      Fixes: da1afe8e ("leds: led-core: Fix refcount leak in of_led_get()")
      Co-developed-by: default avatarHervé Codina <herve.codina@bootlin.com>
      Signed-off-by: default avatarHervé Codina <herve.codina@bootlin.com>
      Signed-off-by: default avatarLuca Ceresoli <luca.ceresoli@bootlin.com>
      Link: https://lore.kernel.org/r/20240625-led-class-device-leak-v2-1-75fdccf47421@bootlin.comSigned-off-by: default avatarLee Jones <lee@kernel.org>
      940b2716
  5. 26 Jun, 2024 32 commits