platform: fix reference leak on failed platform_device_register()
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest5 patches 5 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/5 | misc: eeprom: digsy_mtc: fix reference leak on failed device registrationdrivers/ | +3 | 0 replies | |
| 2/5 | platform/chrome: cros_ec_lpc: fix reference leak on failed device registrationdrivers/ | +1 | 1 reply | |
| 3/5 | mtd: maps: physmap: fix reference leak on failed device registrationdrivers/ | +3 | 1 reply | |
| 4/5 | perf: arm: pmu: fix reference leak on failed device registrationdrivers/ | +3 | 1 reply | |
| 5/5 | mfd: sm501: fix reference leak on failed device registrationdrivers/ | +3 | 7 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/5] platform: fix reference leak on failed platform_device_register()
platform_device_register() calls device_initialize() before platform_device_add(). If platform_device_add() fails, device_initialize() has already set the struct device kref to 1, and the kref must be released via platform_device_put(). The kernel-doc for platform_device_register() states this explicitly:
NOTE: _Never_ directly free @pdev after calling this function, even if it returned an error! Always use platform_device_put() to give up the reference initialised in this function instead.
This series fixes five drivers that call platform_device_register() and return the error code without calling platform_device_put() on the failure path. The pattern was identified by Coccinelle static analysis, confirmed by manual inspection, and is analogous to the recently merged fix in commit 4ff036f95238 ("ALSA: pcmtest: fix reference leak on failed device registration").
Sites fixed:
drivers/misc/eeprom/digsy_mtc_eeprom.c
drivers/platform/chrome/cros_ec_lpc.c
drivers/mtd/maps/physmap-core.c
drivers/perf/arm_pmu_acpi.c
drivers/mfd/sm501.c
Build tested on x86 defconfig:
- digsy_mtc_eeprom.c: compiled cleanly
- cros_ec_lpc.c: compiled cleanly - sm501.c: compiled cleanly - physmap-core.c: pre-existing Werror in map.h header (unrelated) - arm_pmu_acpi.c: ARM-only, no asm/cputype.h on x86
Vastargazing (5):
misc: eeprom: digsy_mtc: fix reference leak on failed device
registration
platform/chrome: cros_ec_lpc: fix reference leak on failed device
registration
mtd: maps: physmap: fix reference leak on failed device registration
perf: arm: pmu: fix reference leak on failed device registration
mfd: sm501: fix reference leak on failed device registration
drivers/mfd/sm501.c | 4 +++- drivers/misc/eeprom/digsy_mtc_eeprom.c | 4 +++- drivers/mtd/maps/physmap-core.c | 4 +++- drivers/perf/arm_pmu_acpi.c | 4 +++- drivers/platform/chrome/cros_ec_lpc.c | 1 + 5 files changed, 13 insertions(+), 4 deletions(-)
Signature · 1 line
2.51.0