Skip to contentSkip to conversation

spi: cs42l43: Property entry should be a null-terminated array

PATCH In review Simon Trimmer 3 participants 5 messages Jul 31, 2025 – Aug 1, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi: cs42l43: Property entry should be a null-terminated array

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.

Fixes 0ca645ab5b15 ("spi: cs42l43: Add speaker id support to the bridge configuration")
---
 drivers/spi/spi-cs42l43.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-cs42l43.c +1 -1
index b28a840b3b04..14307dd800b7 100644
@@ -295,7 +295,7 @@ static struct spi_board_info *cs42l43_create_bridge_amp(struct cs42l43_spi *priv
 	struct spi_board_info *info;
 
 	if (spkid >= 0) {
-		props = devm_kmalloc(priv->dev, sizeof(*props), GFP_KERNEL);
+		props = devm_kcalloc(priv->dev, 2, sizeof(*props), GFP_KERNEL);
 		if (!props)
 			return NULL;
 
Signature · 1 line
2.43.0
maintainer
#1 lore raw

drivers/spi/spi-cs42l43.c static struct spi_board_info *cs42l43_create_bridge_amp(struct cs42l43_spi *priv · line 298

Quoted 10 lines · Simon Trimmer

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.

drivers/spi/spi-cs42l43.c +1 -1
 	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?

#2 lore raw
Quoted 8 lines · Mark Brown
Quoted 6 lines · Simon Trimmer

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.

Quoted 5 lines

drivers/spi/spi-cs42l43.c static struct spi_board_info *cs42l43_create_bridge_amp(struct cs42l43_spi *priv · line 298

Quoted 3 lines
  	if (spkid >= 0) {
drivers/spi/spi-cs42l43.c +1 -1
-		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. "

maintainer
#3 lore raw
In reply to Simon Trimmer
Quoted 8 lines · Simon Trimmer

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.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] spi: cs42l43: Property entry should be a null-terminated array

      commit: a735ee58c0d673d630a10ac2939dccb54df0622a

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

maintainer
#4 lore raw
In reply to Simon Trimmer
Quoted 8 lines · Simon Trimmer

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.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] spi: cs42l43: Property entry should be a null-terminated array

      commit: a735ee58c0d673d630a10ac2939dccb54df0622a

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark