From: Lee Jones <lee@kernel.org>
To: Kunwu Chan <chentao@kylinos.cn>
Cc: jpanis@baylibre.com, kunwu.chan@hotmail.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mfd: tps6594: Add null pointer check to tps6594_device_init
Date: Thu, 7 Dec 2023 16:10:37 +0000 [thread overview]
Message-ID: <20231207161037.GA111411@google.com> (raw)
In-Reply-To: <20231205095426.2532572-1-chentao@kylinos.cn>
On Tue, 05 Dec 2023, Kunwu Chan wrote:
> devm_kasprintf() returns a pointer to dynamically allocated memory
> which can be NULL upon failure.
>
> Fixes: 325bec7157b3 ("mfd: tps6594: Add driver for TI TPS6594 PMIC")
> Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
> ---
> drivers/mfd/tps6594-core.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/mfd/tps6594-core.c b/drivers/mfd/tps6594-core.c
> index 0fb9c5cf213a..6403c1063de9 100644
> --- a/drivers/mfd/tps6594-core.c
> +++ b/drivers/mfd/tps6594-core.c
> @@ -433,6 +433,9 @@ int tps6594_device_init(struct tps6594 *tps, bool enable_crc)
> tps6594_irq_chip.name = devm_kasprintf(dev, GFP_KERNEL, "%s-%ld-0x%02x",
> dev->driver->name, tps->chip_id, tps->reg);
>
> + if (!tps6594_irq_chip.name)
> + return dev_err_probe(dev, -ENOMEM, "Failed to allocate memory\n");
> +
The check is fine, but the use of dev_err_probe() is not.
Simply:
return -ENOMEM;
> ret = devm_regmap_add_irq_chip(dev, tps->regmap, tps->irq, IRQF_SHARED | IRQF_ONESHOT,
> 0, &tps6594_irq_chip, &tps->irq_data);
> if (ret)
> --
> 2.34.1
>
--
Lee Jones [李琼斯]
next prev parent reply other threads:[~2023-12-07 16:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-05 9:54 [PATCH] mfd: tps6594: Add null pointer check to tps6594_device_init Kunwu Chan
2023-12-07 16:10 ` Lee Jones [this message]
2023-12-08 3:24 ` Kunwu Chan
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=20231207161037.GA111411@google.com \
--to=lee@kernel.org \
--cc=chentao@kylinos.cn \
--cc=jpanis@baylibre.com \
--cc=kunwu.chan@hotmail.com \
--cc=linux-kernel@vger.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 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.