From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Jiasheng Jiang <jiashengjiangcool@gmail.com>
Cc: christophe.jaillet@wanadoo.fr, gmpy.liaowx@gmail.com,
kees@kernel.org, linux-kernel@vger.kernel.org,
linux-mtd@lists.infradead.org, richard@nod.at, vigneshr@ti.com,
stable@vger.kernel.org
Subject: Re: [PATCH v2] mtd: Add check and kfree() for kcalloc()
Date: Tue, 04 Feb 2025 10:17:07 +0100 [thread overview]
Message-ID: <87wme683xo.fsf@bootlin.com> (raw)
In-Reply-To: <20250204023323.14213-1-jiashengjiangcool@gmail.com> (Jiasheng Jiang's message of "Tue, 4 Feb 2025 02:33:23 +0000")
Hello,
> --- a/drivers/mtd/mtdpstore.c
> +++ b/drivers/mtd/mtdpstore.c
> @@ -418,10 +418,17 @@ static void mtdpstore_notify_add(struct mtd_info *mtd)
>
> longcnt = BITS_TO_LONGS(div_u64(mtd->size, info->kmsg_size));
> cxt->rmmap = kcalloc(longcnt, sizeof(long), GFP_KERNEL);
> + if (!cxt->rmmap)
> + goto end;
We prefer to return immediately in this case.
Also, any reasons not to use devm_kcalloc()? This would be the correct
approach as of today as long as the lifetime of the device is known.
Thanks,
Miquèl
prev parent reply other threads:[~2025-02-04 9:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <30ad77af-4a7b-4a15-9c0b-b0c70d9e1643@wanadoo.fr>
2025-02-04 2:33 ` [PATCH v2] mtd: Add check and kfree() for kcalloc() Jiasheng Jiang
2025-02-04 6:17 ` Christophe JAILLET
2025-02-04 6:36 ` Jiri Slaby
2025-02-04 20:50 ` Christophe JAILLET
2025-02-05 2:31 ` [PATCH v3 1/2] mtd: Replace kcalloc() with devm_kcalloc() Jiasheng Jiang
2025-02-05 2:31 ` [PATCH v3 2/2] mtd: Add check for devm_kcalloc() Jiasheng Jiang
2025-02-07 14:46 ` [PATCH v3 1/2] mtd: Replace kcalloc() with devm_kcalloc() Miquel Raynal
2025-02-05 2:35 ` [PATCH v2] mtd: Add check and kfree() for kcalloc() Jiasheng Jiang
2025-02-04 6:32 ` Jiri Slaby
2025-02-04 9:17 ` Miquel Raynal [this message]
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=87wme683xo.fsf@bootlin.com \
--to=miquel.raynal@bootlin.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=gmpy.liaowx@gmail.com \
--cc=jiashengjiangcool@gmail.com \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=richard@nod.at \
--cc=stable@vger.kernel.org \
--cc=vigneshr@ti.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 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).