Thread (9 messages) 9 messages, 3 authors, 2023-06-16

Re: [PATCH 1/3] pinctrl: mcp23s08: check return value of devm_kasprintf()

From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: 2023-06-15 11:02:57
Also in: linux-gpio, lkml

On Thu, Jun 15, 2023 at 01:53:31PM +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).
Not that this may happen, but okay.

...
quoted hunk ↗ jump to hunk
@@ -119,6 +119,9 @@ static int mcp23s08_spi_regmap_init(struct mcp23s08 *mcp, struct device *dev,
 		return -EINVAL;
 	}
 
+	if (!name || !mcp->chip.label)
+		return -ENOMEM;
I prefer to see 4 independent checks for each of the devm_kasprintf() calls.

-- 
With Best Regards,
Andy Shevchenko



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help