1. 28 11月, 2022 1 次提交
    • Z
      gpiolib: fix memory leak in gpiochip_setup_dev() · ec851b23
      Zeng Heng 提交于
      Here is a backtrace report about memory leak detected in
      gpiochip_setup_dev():
      
      unreferenced object 0xffff88810b406400 (size 512):
        comm "python3", pid 1682, jiffies 4295346908 (age 24.090s)
        backtrace:
          kmalloc_trace
          device_add		device_private_init at drivers/base/core.c:3361
      			(inlined by) device_add at drivers/base/core.c:3411
          cdev_device_add
          gpiolib_cdev_register
          gpiochip_setup_dev
          gpiochip_add_data_with_key
      
      gcdev_register() & gcdev_unregister() would call device_add() &
      device_del() (no matter CONFIG_GPIO_CDEV is enabled or not) to
      register/unregister device.
      
      However, if device_add() succeeds, some resource (like
      struct device_private allocated by device_private_init())
      is not released by device_del().
      
      Therefore, after device_add() succeeds by gcdev_register(), it
      needs to call put_device() to release resource in the error handle
      path.
      
      Here we move forward the register of release function, and let it
      release every piece of resource by put_device() instead of kfree().
      
      While at it, fix another subtle issue, i.e. when gc->ngpio is equal
      to 0, we still call kcalloc() and, in case of further error, kfree()
      on the ZERO_PTR pointer, which is not NULL. It's not a bug per se,
      but rather waste of the resources and potentially wrong expectation
      about contents of the gdev->descs variable.
      
      Fixes: 159f3cd9 ("gpiolib: Defer gpio device setup until after gpiolib initialization")
      Signed-off-by: NZeng Heng <zengheng4@huawei.com>
      Co-developed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NBartosz Golaszewski <bartosz.golaszewski@linaro.org>
      ec851b23
  2. 05 9月, 2022 1 次提交
  3. 19 7月, 2022 1 次提交
  4. 10 7月, 2022 2 次提交
  5. 04 5月, 2022 1 次提交
  6. 23 4月, 2022 1 次提交
  7. 19 4月, 2022 2 次提交
  8. 10 4月, 2022 5 次提交
  9. 05 4月, 2022 1 次提交
  10. 04 4月, 2022 1 次提交
  11. 16 3月, 2022 1 次提交
  12. 08 3月, 2022 1 次提交
  13. 07 3月, 2022 2 次提交
  14. 24 2月, 2022 1 次提交
    • S
      gpio: Return EPROBE_DEFER if gc->to_irq is NULL · ae42f928
      Shreeya Patel 提交于
      We are racing the registering of .to_irq when probing the
      i2c driver. This results in random failure of touchscreen
      devices.
      
      Following explains the race condition better.
      
      [gpio driver] gpio driver registers gpio chip
      [gpio consumer] gpio is acquired
      [gpio consumer] gpiod_to_irq() fails with -ENXIO
      [gpio driver] gpio driver registers irqchip
      gpiod_to_irq works at this point, but -ENXIO is fatal
      
      We could see the following errors in dmesg logs when gc->to_irq is NULL
      
      [2.101857] i2c_hid i2c-FTS3528:00: HID over i2c has not been provided an Int IRQ
      [2.101953] i2c_hid: probe of i2c-FTS3528:00 failed with error -22
      
      To avoid this situation, defer probing until to_irq is registered.
      Returning -EPROBE_DEFER would be the first step towards avoiding
      the failure of devices due to the race in registration of .to_irq.
      Final solution to this issue would be to avoid using gc irq members
      until they are fully initialized.
      
      This issue has been reported many times in past and people have been
      using workarounds like changing the pinctrl_amd to built-in instead
      of loading it as a module or by adding a softdep for pinctrl_amd into
      the config file.
      
      BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=209413Reviewed-by: NLinus Walleij <linus.walleij@linaro.org>
      Reviewed-by: NAndy Shevchenko <andy.shevchenko@gmail.com>
      Reported-by: Nkernel test robot <lkp@intel.com>
      Signed-off-by: NShreeya Patel <shreeya.patel@collabora.com>
      Signed-off-by: NBartosz Golaszewski <brgl@bgdev.pl>
      ae42f928
  15. 08 2月, 2022 3 次提交
  16. 17 12月, 2021 3 次提交
  17. 06 12月, 2021 2 次提交
  18. 03 12月, 2021 1 次提交
  19. 27 10月, 2021 1 次提交
  20. 30 7月, 2021 1 次提交
  21. 28 5月, 2021 2 次提交
  22. 12 5月, 2021 1 次提交
  23. 26 3月, 2021 5 次提交