Skip to content

Commit 74ac5b5

Browse files
Yi Yangmiquelraynal
authored andcommitted
mtd: rawnand: intel: 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: 0b1039f ("mtd: rawnand: Add NAND controller support on Intel LGM SoC") Signed-off-by: Yi Yang <yiyang13@huawei.com> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/linux-mtd/20231019065537.318391-1-yiyang13@huawei.com
1 parent 60ec53a commit 74ac5b5

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

drivers/mtd/nand/raw/intel-nand-controller.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,11 @@ static int ebu_nand_probe(struct platform_device *pdev)
619619
ebu_host->cs_num = cs;
620620

621621
resname = devm_kasprintf(dev, GFP_KERNEL, "nand_cs%d", cs);
622+
if (!resname) {
623+
ret = -ENOMEM;
624+
goto err_of_node_put;
625+
}
626+
622627
ebu_host->cs[cs].chipaddr = devm_platform_ioremap_resource_byname(pdev,
623628
resname);
624629
if (IS_ERR(ebu_host->cs[cs].chipaddr)) {
@@ -649,6 +654,11 @@ static int ebu_nand_probe(struct platform_device *pdev)
649654
}
650655

651656
resname = devm_kasprintf(dev, GFP_KERNEL, "addr_sel%d", cs);
657+
if (!resname) {
658+
ret = -ENOMEM;
659+
goto err_cleanup_dma;
660+
}
661+
652662
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, resname);
653663
if (!res) {
654664
ret = -EINVAL;

0 commit comments

Comments
 (0)