linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drivers/perf: fix return value check in ali_drw_pmu_probe()
@ 2022-09-24  3:21 Sun Ke
  2022-09-26  1:14 ` Shuai Xue
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sun Ke @ 2022-09-24  3:21 UTC (permalink / raw)
  To: will, mark.rutland
  Cc: linux-arm-kernel, linux-kernel, kernel-janitors, xueshuai, sunke32

In case of error, devm_ioremap_resource() returns ERR_PTR(),
and never returns NULL. The NULL test in the return value
check should be replaced with IS_ERR().

Fixes: cf7b61073e45 ("drivers/perf: add DDR Sub-System Driveway PMU driver for Yitian 710 SoC")
Signed-off-by: Sun Ke <sunke32@huawei.com>
---
 drivers/perf/alibaba_uncore_drw_pmu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/perf/alibaba_uncore_drw_pmu.c b/drivers/perf/alibaba_uncore_drw_pmu.c
index 82729b874f09..a7689fecb49d 100644
--- a/drivers/perf/alibaba_uncore_drw_pmu.c
+++ b/drivers/perf/alibaba_uncore_drw_pmu.c
@@ -658,8 +658,8 @@ static int ali_drw_pmu_probe(struct platform_device *pdev)
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	drw_pmu->cfg_base = devm_ioremap_resource(&pdev->dev, res);
-	if (!drw_pmu->cfg_base)
-		return -ENOMEM;
+	if (IS_ERR(drw_pmu->cfg_base))
+		return PTR_ERR(drw_pmu->cfg_base);
 
 	name = devm_kasprintf(drw_pmu->dev, GFP_KERNEL, "ali_drw_%llx",
 			      (u64) (res->start >> ALI_DRW_PMU_PA_SHIFT));
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] drivers/perf: fix return value check in ali_drw_pmu_probe()
  2022-09-24  3:21 [PATCH] drivers/perf: fix return value check in ali_drw_pmu_probe() Sun Ke
@ 2022-09-26  1:14 ` Shuai Xue
  2022-10-07 13:15 ` Will Deacon
  2022-10-07 16:44 ` Catalin Marinas
  2 siblings, 0 replies; 4+ messages in thread
From: Shuai Xue @ 2022-09-26  1:14 UTC (permalink / raw)
  To: Sun Ke, will, mark.rutland
  Cc: linux-arm-kernel, linux-kernel, kernel-janitors



在 2022/9/24 AM11:21, Sun Ke 写道:
> In case of error, devm_ioremap_resource() returns ERR_PTR(),
> and never returns NULL. The NULL test in the return value
> check should be replaced with IS_ERR().
> 
> Fixes: cf7b61073e45 ("drivers/perf: add DDR Sub-System Driveway PMU driver for Yitian 710 SoC")
> Signed-off-by: Sun Ke <sunke32@huawei.com>

Good catch, thank you for fixing.

Reviewed-by: Shuai Xue <xueshuai@linux.alibaba.com>

Cheers,
Shuai



> ---
>  drivers/perf/alibaba_uncore_drw_pmu.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/perf/alibaba_uncore_drw_pmu.c b/drivers/perf/alibaba_uncore_drw_pmu.c
> index 82729b874f09..a7689fecb49d 100644
> --- a/drivers/perf/alibaba_uncore_drw_pmu.c
> +++ b/drivers/perf/alibaba_uncore_drw_pmu.c
> @@ -658,8 +658,8 @@ static int ali_drw_pmu_probe(struct platform_device *pdev)
>  
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	drw_pmu->cfg_base = devm_ioremap_resource(&pdev->dev, res);
> -	if (!drw_pmu->cfg_base)
> -		return -ENOMEM;
> +	if (IS_ERR(drw_pmu->cfg_base))
> +		return PTR_ERR(drw_pmu->cfg_base);
>  
>  	name = devm_kasprintf(drw_pmu->dev, GFP_KERNEL, "ali_drw_%llx",
>  			      (u64) (res->start >> ALI_DRW_PMU_PA_SHIFT));

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drivers/perf: fix return value check in ali_drw_pmu_probe()
  2022-09-24  3:21 [PATCH] drivers/perf: fix return value check in ali_drw_pmu_probe() Sun Ke
  2022-09-26  1:14 ` Shuai Xue
@ 2022-10-07 13:15 ` Will Deacon
  2022-10-07 16:44 ` Catalin Marinas
  2 siblings, 0 replies; 4+ messages in thread
From: Will Deacon @ 2022-10-07 13:15 UTC (permalink / raw)
  To: Sun Ke, catalin.marinas
  Cc: mark.rutland, linux-arm-kernel, linux-kernel, kernel-janitors, xueshuai

On Sat, Sep 24, 2022 at 11:21:27AM +0800, Sun Ke wrote:
> In case of error, devm_ioremap_resource() returns ERR_PTR(),
> and never returns NULL. The NULL test in the return value
> check should be replaced with IS_ERR().
> 
> Fixes: cf7b61073e45 ("drivers/perf: add DDR Sub-System Driveway PMU driver for Yitian 710 SoC")
> Signed-off-by: Sun Ke <sunke32@huawei.com>
> ---
>  drivers/perf/alibaba_uncore_drw_pmu.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/perf/alibaba_uncore_drw_pmu.c b/drivers/perf/alibaba_uncore_drw_pmu.c
> index 82729b874f09..a7689fecb49d 100644
> --- a/drivers/perf/alibaba_uncore_drw_pmu.c
> +++ b/drivers/perf/alibaba_uncore_drw_pmu.c
> @@ -658,8 +658,8 @@ static int ali_drw_pmu_probe(struct platform_device *pdev)
>  
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	drw_pmu->cfg_base = devm_ioremap_resource(&pdev->dev, res);
> -	if (!drw_pmu->cfg_base)
> -		return -ENOMEM;
> +	if (IS_ERR(drw_pmu->cfg_base))
> +		return PTR_ERR(drw_pmu->cfg_base);
>  
>  	name = devm_kasprintf(drw_pmu->dev, GFP_KERNEL, "ali_drw_%llx",
>  			      (u64) (res->start >> ALI_DRW_PMU_PA_SHIFT));

Acked-by: Will Deacon <will@kernel.org>

Catalin can pick this one up as a fix.

Cheers,

Will

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drivers/perf: fix return value check in ali_drw_pmu_probe()
  2022-09-24  3:21 [PATCH] drivers/perf: fix return value check in ali_drw_pmu_probe() Sun Ke
  2022-09-26  1:14 ` Shuai Xue
  2022-10-07 13:15 ` Will Deacon
@ 2022-10-07 16:44 ` Catalin Marinas
  2 siblings, 0 replies; 4+ messages in thread
From: Catalin Marinas @ 2022-10-07 16:44 UTC (permalink / raw)
  To: mark.rutland, will, Sun Ke
  Cc: kernel-janitors, linux-kernel, linux-arm-kernel, xueshuai

On Sat, 24 Sep 2022 11:21:27 +0800, Sun Ke wrote:
> In case of error, devm_ioremap_resource() returns ERR_PTR(),
> and never returns NULL. The NULL test in the return value
> check should be replaced with IS_ERR().
> 
> 

Applied to arm64 (for-next/core), thanks!

[1/1] drivers/perf: fix return value check in ali_drw_pmu_probe()
      https://git.kernel.org/arm64/c/ad0112f2d54c

-- 
Catalin


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-07 16:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-24  3:21 [PATCH] drivers/perf: fix return value check in ali_drw_pmu_probe() Sun Ke
2022-09-26  1:14 ` Shuai Xue
2022-10-07 13:15 ` Will Deacon
2022-10-07 16:44 ` Catalin Marinas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).