On Wed, Jun 21, 2023 at 01:04:09PM +0300, Claudiu Beznea wrote: > devm_kasprintf() returns a pointer to dynamically allocated memory. > Pointer could be NULL in case allocation fails. Check pointer validity. > Identified with coccinelle (kmerr.cocci script). Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> > Fixes: 0f04a81784fe ("pinctrl: mcp23s08: Split to three parts: core, I²C, SPI") > Signed-off-by: Claudiu Beznea <claudiu.beznea@xxxxxxxxxxxxx> > --- > > Changes in v2: > - use independent checks for devm_kasprintf() > > drivers/pinctrl/pinctrl-mcp23s08_spi.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/drivers/pinctrl/pinctrl-mcp23s08_spi.c b/drivers/pinctrl/pinctrl-mcp23s08_spi.c > index 9ae10318f6f3..ea059b9c5542 100644 > --- a/drivers/pinctrl/pinctrl-mcp23s08_spi.c > +++ b/drivers/pinctrl/pinctrl-mcp23s08_spi.c > @@ -91,18 +91,28 @@ static int mcp23s08_spi_regmap_init(struct mcp23s08 *mcp, struct device *dev, > mcp->reg_shift = 0; > mcp->chip.ngpio = 8; > mcp->chip.label = devm_kasprintf(dev, GFP_KERNEL, "mcp23s08.%d", addr); > + if (!mcp->chip.label) > + return -ENOMEM; > > config = &mcp23x08_regmap; > name = devm_kasprintf(dev, GFP_KERNEL, "%d", addr); > + if (!name) > + return -ENOMEM; > + > break; > > case MCP_TYPE_S17: > mcp->reg_shift = 1; > mcp->chip.ngpio = 16; > mcp->chip.label = devm_kasprintf(dev, GFP_KERNEL, "mcp23s17.%d", addr); > + if (!mcp->chip.label) > + return -ENOMEM; > > config = &mcp23x17_regmap; > name = devm_kasprintf(dev, GFP_KERNEL, "%d", addr); > + if (!name) > + return -ENOMEM; > + > break; > > case MCP_TYPE_S18: > -- > 2.34.1 > -- With Best Regards, Andy Shevchenko