From: Jiasheng Jiang <jiashengjiangcool@gmail.com>
To: christophe.jaillet@wanadoo.fr
Cc: gmpy.liaowx@gmail.com, jiashengjiangcool@gmail.com,
jirislaby@kernel.org, kees@kernel.org,
linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org,
miquel.raynal@bootlin.com, richard@nod.at,
stable@vger.kernel.org, vigneshr@ti.com
Subject: [PATCH v3 2/2] mtd: Add check for devm_kcalloc()
Date: Wed, 5 Feb 2025 02:31:41 +0000 [thread overview]
Message-ID: <20250205023141.26195-2-jiashengjiangcool@gmail.com> (raw)
In-Reply-To: <20250205023141.26195-1-jiashengjiangcool@gmail.com>
Add a check for devm_kcalloc() to ensure successful allocation.
Fixes: 78c08247b9d3 ("mtd: Support kmsg dumper based on pstore/blk")
Cc: <stable@vger.kernel.org> # v5.10+
Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>
---
Changelog:
v2 -> v3:
1. No change.
v1 -> v2:
1. No change.
---
drivers/mtd/mtdpstore.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/mtd/mtdpstore.c b/drivers/mtd/mtdpstore.c
index 2d004d41cf75..9cf3872e37ae 100644
--- a/drivers/mtd/mtdpstore.c
+++ b/drivers/mtd/mtdpstore.c
@@ -423,6 +423,9 @@ static void mtdpstore_notify_add(struct mtd_info *mtd)
longcnt = BITS_TO_LONGS(div_u64(mtd->size, mtd->erasesize));
cxt->badmap = devm_kcalloc(&mtd->dev, longcnt, sizeof(long), GFP_KERNEL);
+ if (!cxt->rmmap || !cxt->usedmap || !cxt->badmap)
+ return;
+
/* just support dmesg right now */
cxt->dev.flags = PSTORE_FLAGS_DMESG;
cxt->dev.zone.read = mtdpstore_read;
--
2.25.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2025-02-05 2:31 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-02 20:54 [PATCH] mtd: Add check for kcalloc() Jiasheng Jiang
2025-02-03 8:32 ` Miquel Raynal
2025-02-03 18:04 ` Christophe JAILLET
2025-02-04 2:33 ` [PATCH v2] mtd: Add check and kfree() " 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 ` Jiasheng Jiang [this message]
2025-02-07 14:46 ` 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
2025-02-04 2:37 ` [PATCH] mtd: Add check " Jiasheng Jiang
2025-02-04 2:34 ` Jiasheng Jiang
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=20250205023141.26195-2-jiashengjiangcool@gmail.com \
--to=jiashengjiangcool@gmail.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=gmpy.liaowx@gmail.com \
--cc=jirislaby@kernel.org \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--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