Skip to content

Commit 2920294

Browse files
Charles Hanbroonie
authored andcommitted
spi: intel: Add check devm_kasprintf() returned value
intel_spi_populate_chip() use devm_kasprintf() to set pdata->name. This can return a NULL pointer on failure but this returned value is not checked. Fixes: e58db3b ("spi: intel: Add default partition and name to the second chip") Signed-off-by: Charles Han <[email protected]> Reviewed-by: Mika Westerberg <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 5f3eee1 commit 2920294

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/spi/spi-intel.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,6 +1390,9 @@ static int intel_spi_populate_chip(struct intel_spi *ispi)
13901390

13911391
pdata->name = devm_kasprintf(ispi->dev, GFP_KERNEL, "%s-chip1",
13921392
dev_name(ispi->dev));
1393+
if (!pdata->name)
1394+
return -ENOMEM;
1395+
13931396
pdata->nr_parts = 1;
13941397
parts = devm_kcalloc(ispi->dev, pdata->nr_parts, sizeof(*parts),
13951398
GFP_KERNEL);

0 commit comments

Comments
 (0)