Re: [PATCH] ARM: OMAP2+: Hold reference returned from of_find_xxx API

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

 



On Thu, Sep 15, 2022 at 09:42:58AM +0800, Liang He wrote:
> In omap4_twl_init(), we should hold the reference returned from
> of_find_compatible_node() which has increased the refcount and
> then call of_node_put() with it when done.
> 
> Fixes: ccd369455a23 ("ARM: OMAP2+: Remove bogus warnings for machines without twl PMIC")
> Signed-off-by: Liang He <windhl@xxxxxxx>
> Signed-off-by: Mengda Chen <chenmengda2009@xxxxxxx>
> ---
>  arch/arm/mach-omap2/omap_twl.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/omap_twl.c b/arch/arm/mach-omap2/omap_twl.c
> index d4dab041324d..07b5f17066ce 100644
> --- a/arch/arm/mach-omap2/omap_twl.c
> +++ b/arch/arm/mach-omap2/omap_twl.c
> @@ -213,11 +213,13 @@ 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"))
> +	    (np = of_find_compatible_node(NULL, NULL, "motorola,cpcap"))) {
> +		of_node_put(np);

This is buggy - if cpu_is_omap44xx() is false, then np will not be
initialised. The simple solution is to initialise np to NULL.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!



[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux