Re: [PATCH] spi: cs42l43: Property entry should be a null-terminated array

From: Richard Fitzgerald
Date: Thu Jul 31 2025 - 12:21:42 EST


On 31/07/2025 5:20 pm, Mark Brown wrote:
On Thu, Jul 31, 2025 at 04:01:09PM +0000, Simon Trimmer wrote:
The software node does not specify a count of property entries, so the
array must be null-terminated.

When unterminated, this can lead to a fault in the downstream cs35l56
amplifier driver, because the node parse walks off the end of the
array into unknown memory.

if (spkid >= 0) {
- props = devm_kmalloc(priv->dev, sizeof(*props), GFP_KERNEL);
+ props = devm_kcalloc(priv->dev, 2, sizeof(*props), GFP_KERNEL);

Does kcalloc() zero initialise the data?

"kcalloc — allocate memory for an array. The memory is set to zero. "