ARM: OMAP2+: Fix CPCAP node reference leaks
PATCH 1/1 ARM: OMAP2+: Fix CPCAP node reference leaks
omap4_cpcap_init(), cpcap_late_init() and omap4_twl_init() call of_find_compatible_node() to check whether the device tree has a "motorola,cpcap" node. of_find_compatible_node() returns the node with its reference count raised, but the callers only test the returned pointer and never drop that reference.
Put the node right after the check.
Fixes d44fa156dcb2 ("ARM: OMAP2+: Configure voltage controller for cpcap")
Fixes ccd369455a23 ("ARM: OMAP2+: Remove bogus warnings for machines without twl PMIC")
Fixes 7397daf1029d ("ARM: omap: pmic-cpcap: do not mess around without CPCAP or OMAP4")
Signed-off-by Yuho Choi <[email protected]>
---
Compile-tested only (ARM omap2plus_defconfig, W=1). I have no OMAP4 board with a CPCAP PMIC to test it on.
arch/arm/mach-omap2/omap_twl.c | 10 ++++++++-- arch/arm/mach-omap2/pmic-cpcap.c | 11 +++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-)
arch/arm/mach-omap2/omap_twl.c +8 -2
@@ -213,11 +213,17 @@ static struct omap_voltdm_pmic omap4_core_pmic = {int __init omap4_twl_init (void ) {struct voltagedomain *voltdm; +struct device_node *np; -if (!cpu_is_omap44xx () || -of_find_compatible_node (NULL ,NULL ,"motorola,cpcap" )) +if (!cpu_is_omap44xx ())return -ENODEV ; + np =of_find_compatible_node (NULL ,NULL ,"motorola,cpcap" ); +if (np) { +of_node_put (np); +return -ENODEV ; + } + voltdm =voltdm_lookup ("mpu" );omap_voltage_register_pmic (voltdm, &omap4_mpu_pmic);
arch/arm/mach-omap2/pmic-cpcap.c +9 -2
@@ -238,9 +238,12 @@ static struct omap_voltdm_pmic omap4_fan_iva = {int __init omap4_cpcap_init (void ) {struct voltagedomain *voltdm; +struct device_node *np; -if (!of_find_compatible_node (NULL ,NULL ,"motorola,cpcap" )) + np =of_find_compatible_node (NULL ,NULL ,"motorola,cpcap" ); +if (!np)return -ENODEV ; +of_node_put (np); voltdm =voltdm_lookup ("mpu" );omap_voltage_register_pmic (voltdm, &omap443x_max8952_mpu);
@@ -264,8 +267,12 @@ int __init omap4_cpcap_init(void)static int __init cpcap_late_init (void ) { -if (!of_find_compatible_node (NULL ,NULL ,"motorola,cpcap" )) +struct device_node *np; + + np =of_find_compatible_node (NULL ,NULL ,"motorola,cpcap" ); +if (!np)return 0 ; +of_node_put (np);if (soc_is_omap443x () ||soc_is_omap446x () ||soc_is_omap447x ())omap4_vc_set_pmic_signaling (PWRDM_POWER_RET );
base-commit: 8dac6df92a2e66e2098bbc69061964cfe7e8375b
Signature · 1 line
2.56.1