Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: Peng Fan <peng.fan@oss.nxp.com>
To: Yuanjun Gong <ruc_gongyuanjun@163.com>
Cc: Will Deacon <will@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Shawn Guo <shawnguo@kernel.org>,
	imx@lists.linux.dev
Subject: Re: [PATCH 1/1] Add check to ida_alloc()
Date: Fri, 16 May 2025 11:59:04 +0800	[thread overview]
Message-ID: <20250516035904.GA28759@nxa18884-linux> (raw)
In-Reply-To: <20250513123705.3041311-1-ruc_gongyuanjun@163.com>

On Tue, May 13, 2025 at 08:37:05PM +0800, Yuanjun Gong wrote:
>Check the return value of ida_alloc() in case it fails.
>This is found by a static checker.
>
>Signed-off-by: Yuanjun Gong <ruc_gongyuanjun@163.com>
>---
> drivers/perf/fsl_imx9_ddr_perf.c | 3 +++
> 1 file changed, 3 insertions(+)
>
>diff --git a/drivers/perf/fsl_imx9_ddr_perf.c b/drivers/perf/fsl_imx9_ddr_perf.c
>index 843f163e6c33..86da027405cf 100644
>--- a/drivers/perf/fsl_imx9_ddr_perf.c
>+++ b/drivers/perf/fsl_imx9_ddr_perf.c
>@@ -790,6 +790,9 @@ static int ddr_perf_probe(struct platform_device *pdev)
> 	platform_set_drvdata(pdev, pmu);
> 
> 	pmu->id = ida_alloc(&ddr_ida, GFP_KERNEL);
>+	if (pmu->id < 0)
>+		return -ENOMEM;

I would write this as:
ret = ida_alloc(&ddr_ida, GFP_KERNEL);
if (ret < 0)
    return ret;

pmu->id = ret;

Regards,
Peng

>+
> 	name = devm_kasprintf(&pdev->dev, GFP_KERNEL, DDR_PERF_DEV_NAME "%d", pmu->id);
> 	if (!name) {
> 		ret = -ENOMEM;
>-- 
>2.25.1
>

  reply	other threads:[~2025-05-16  2:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-13 12:37 [PATCH 1/1] Add check to ida_alloc() Yuanjun Gong
2025-05-16  3:59 ` Peng Fan [this message]
2025-05-16  7:33   ` [PATCH v2 " Yuanjun Gong
2025-05-16  8:42     ` Daniel Baluta
2025-05-19 12:40       ` Will Deacon

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=20250516035904.GA28759@nxa18884-linux \
    --to=peng.fan@oss.nxp.com \
    --cc=imx@lists.linux.dev \
    --cc=mark.rutland@arm.com \
    --cc=ruc_gongyuanjun@163.com \
    --cc=shawnguo@kernel.org \
    --cc=will@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox