All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: yu kuai <yukuai3@huawei.com>
Cc: yi.zhang@huawei.com, linux-kernel@vger.kernel.org,
	linux@armlinux.org.uk, ludovic.desroches@microchip.com,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] ARM: at91: pm: add missing put_device() call in at91_pm_sram_init()
Date: Thu, 2 Jul 2020 22:09:15 +0200	[thread overview]
Message-ID: <20200702200915.GC6538@piout.net> (raw)
In-Reply-To: <20200604123301.3905837-1-yukuai3@huawei.com>

Hi,

On 04/06/2020 20:33:01+0800, yu kuai wrote:
> if of_find_device_by_node() succeed, at91_pm_sram_init() doesn't have
> a corresponding put_device(). Thus add a jump target to fix the exception
> handling for this function implementation.
> 
> Fixes: d2e467905596 ("ARM: at91: pm: use the mmio-sram pool to access SRAM")
> Signed-off-by: yu kuai <yukuai3@huawei.com>
> ---
>  arch/arm/mach-at91/pm.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
> index 074bde64064e..2aab043441e8 100644
> --- a/arch/arm/mach-at91/pm.c
> +++ b/arch/arm/mach-at91/pm.c
> @@ -592,13 +592,13 @@ static void __init at91_pm_sram_init(void)
>  	sram_pool = gen_pool_get(&pdev->dev, NULL);

Isn't the best solution to simply have put_device here?

>  	if (!sram_pool) {
>  		pr_warn("%s: sram pool unavailable!\n", __func__);
> -		return;
> +		goto out_put_device;
>  	}
>  
>  	sram_base = gen_pool_alloc(sram_pool, at91_pm_suspend_in_sram_sz);
>  	if (!sram_base) {
>  		pr_warn("%s: unable to alloc sram!\n", __func__);
> -		return;
> +		goto out_put_device;
>  	}
>  
>  	sram_pbase = gen_pool_virt_to_phys(sram_pool, sram_base);
> @@ -606,12 +606,17 @@ static void __init at91_pm_sram_init(void)
>  					at91_pm_suspend_in_sram_sz, false);
>  	if (!at91_suspend_sram_fn) {
>  		pr_warn("SRAM: Could not map\n");
> -		return;
> +		goto out_put_device;
>  	}
>  
>  	/* Copy the pm suspend handler to SRAM */
>  	at91_suspend_sram_fn = fncpy(at91_suspend_sram_fn,
>  			&at91_pm_suspend_in_sram, at91_pm_suspend_in_sram_sz);
> +	return;
> +
> +out_put_device:
> +	put_device(&pdev->dev);
> +	return;
>  }
>  
>  static bool __init at91_is_pm_mode_active(int pm_mode)
> -- 
> 2.25.4
> 

-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: yu kuai <yukuai3@huawei.com>
Cc: linux@armlinux.org.uk, nicolas.ferre@microchip.com,
	ludovic.desroches@microchip.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, yi.zhang@huawei.com
Subject: Re: [PATCH] ARM: at91: pm: add missing put_device() call in at91_pm_sram_init()
Date: Thu, 2 Jul 2020 22:09:15 +0200	[thread overview]
Message-ID: <20200702200915.GC6538@piout.net> (raw)
In-Reply-To: <20200604123301.3905837-1-yukuai3@huawei.com>

Hi,

On 04/06/2020 20:33:01+0800, yu kuai wrote:
> if of_find_device_by_node() succeed, at91_pm_sram_init() doesn't have
> a corresponding put_device(). Thus add a jump target to fix the exception
> handling for this function implementation.
> 
> Fixes: d2e467905596 ("ARM: at91: pm: use the mmio-sram pool to access SRAM")
> Signed-off-by: yu kuai <yukuai3@huawei.com>
> ---
>  arch/arm/mach-at91/pm.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
> index 074bde64064e..2aab043441e8 100644
> --- a/arch/arm/mach-at91/pm.c
> +++ b/arch/arm/mach-at91/pm.c
> @@ -592,13 +592,13 @@ static void __init at91_pm_sram_init(void)
>  	sram_pool = gen_pool_get(&pdev->dev, NULL);

Isn't the best solution to simply have put_device here?

>  	if (!sram_pool) {
>  		pr_warn("%s: sram pool unavailable!\n", __func__);
> -		return;
> +		goto out_put_device;
>  	}
>  
>  	sram_base = gen_pool_alloc(sram_pool, at91_pm_suspend_in_sram_sz);
>  	if (!sram_base) {
>  		pr_warn("%s: unable to alloc sram!\n", __func__);
> -		return;
> +		goto out_put_device;
>  	}
>  
>  	sram_pbase = gen_pool_virt_to_phys(sram_pool, sram_base);
> @@ -606,12 +606,17 @@ static void __init at91_pm_sram_init(void)
>  					at91_pm_suspend_in_sram_sz, false);
>  	if (!at91_suspend_sram_fn) {
>  		pr_warn("SRAM: Could not map\n");
> -		return;
> +		goto out_put_device;
>  	}
>  
>  	/* Copy the pm suspend handler to SRAM */
>  	at91_suspend_sram_fn = fncpy(at91_suspend_sram_fn,
>  			&at91_pm_suspend_in_sram, at91_pm_suspend_in_sram_sz);
> +	return;
> +
> +out_put_device:
> +	put_device(&pdev->dev);
> +	return;
>  }
>  
>  static bool __init at91_is_pm_mode_active(int pm_mode)
> -- 
> 2.25.4
> 

-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

  parent reply	other threads:[~2020-07-02 20:11 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-04 12:33 [PATCH] ARM: at91: pm: add missing put_device() call in at91_pm_sram_init() yu kuai
2020-06-04 12:33 ` yu kuai
2020-06-24  8:46 ` yukuai (C)
2020-06-24  8:46   ` yukuai (C)
2020-07-02 20:09 ` Alexandre Belloni [this message]
2020-07-02 20:09   ` Alexandre Belloni
2020-07-03  1:15   ` yukuai (C)
2020-07-03  1:15     ` yukuai (C)
2020-07-17 22:55     ` Alexandre Belloni
2020-07-17 22:55       ` Alexandre Belloni
2020-07-21 13:11       ` yukuai (C)
2020-07-21 13:11         ` yukuai (C)
2020-07-17 23:00 ` Alexandre Belloni
2020-07-17 23:00   ` Alexandre Belloni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200702200915.GC6538@piout.net \
    --to=alexandre.belloni@bootlin.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=ludovic.desroches@microchip.com \
    --cc=yi.zhang@huawei.com \
    --cc=yukuai3@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.