Skip to contentSkip to conversation

mtd: rawnand: meson: check return value of devm_kasprintf()

PATCH Applied Yi Yang 2 participants 2 messages Oct 19, 2023 – Oct 27, 2023

Subsystems (4)
lore
Share & tools
lore

Yi Yang

author
#0 lore raw

PATCH v3 1/1 mtd: rawnand: meson: check return value of devm_kasprintf()

devm_kasprintf() returns a pointer to dynamically allocated memory which can be NULL upon failure. Ensure the allocation was successful by checking the pointer validity.

Fixes 1e4d3ba66888 ("mtd: rawnand: meson: fix the clock")

---
v2:Change commit log, and fix error check code. v3:No need for error messages upon memory allocation failures.

---
 drivers/mtd/nand/raw/meson_nand.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/mtd/nand/raw/meson_nand.c +3 -0
index 378f28ce6a74..71ec4052e52a 100644
@@ -1134,6 +1134,9 @@ static int meson_nfc_clk_init(struct meson_nfc *nfc)
 	init.name = devm_kasprintf(nfc->dev,
 				   GFP_KERNEL, "%s#div",
 				   dev_name(nfc->dev));
+	if (!init.name)
+		return -ENOMEM;
+
 	init.ops = &clk_divider_ops;
 	nfc_divider_parent_data[0].fw_name = "device";
 	init.parent_data = nfc_divider_parent_data;
Signature · 6 lines
2.25.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
maintainer Applied
#1 lore raw
Quoted 6 lines · Yi Yang

devm_kasprintf() returns a pointer to dynamically allocated memory which can be NULL upon failure. Ensure the allocation was successful by checking the pointer validity.

Fixes 1e4d3ba66888 ("mtd: rawnand: meson: fix the clock")

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/