Skip to contentSkip to conversation

drm/bridge: sii902x: validate I2S data lane values

PATCH Applied Pengpeng Hou 2 participants 3 messages Sep 20 – Nov 11

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

PATCH v2 1/1 drm/bridge: sii902x: validate I2S data lane values

The sil,i2s-data-lanes property reader bounds the number of entries, but does not bound each entry's value. Those values index the four-entry i2s_lane_id table when the audio FIFO sequence is built.

Reject unsupported lane values before indexing that table. Report the property name and invalid value with dev_err_probe() so the diagnostic identifies the faulty configuration.

The issue was found by our static-analysis tool.

Fixes ff5781634c41 ("drm/bridge: sii902x: Implement HDMI audio support")
Assisted-by gpt 5

---
Changes since v1:
https://lore.kernel.org/all/2026063007056160.5-ccfa108-0046-drm-bridge-sii902x-validate-pengpeng@iscas.ac.cn/
Use dev_err_probe() and identify sil,i2s-data-lanes in the diagnostic, as Luca requested; add the verified introducing Fixes tag.

 drivers/gpu/drm/bridge/sii902x.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/bridge/sii902x.c +7 -1
index 9aac44ed5b67..48058029fdfc 100644
@@ -890,9 +890,15 @@ static int sii902x_audio_codec_init(struct sii902x *sii902x,
 	}
 	codec_data.max_i2s_channels = 2 * num_lanes;
 
-	for (i = 0; i < num_lanes; i++)
+	for (i = 0; i < num_lanes; i++) {
+		if (lanes[i] >= ARRAY_SIZE(i2s_lane_id))
+			return dev_err_probe(dev, -EINVAL,
+					     "invalid sil,i2s-data-lanes value %u\n",
+					     lanes[i]);
+
 		sii902x->audio.i2s_fifo_sequence[i] |= audio_fifo_id[i] |
 			i2s_lane_id[lanes[i]] |	SII902X_TPI_I2S_FIFO_ENABLE;
+	}
 
 	sii902x->audio.mclk = devm_clk_get_optional(dev, "mclk");
 	if (IS_ERR(sii902x->audio.mclk)) {

base-commit: 518e5b794c06c0f0eb40df3e202274a66202c137

Signature · 1 line
2.50.1 (Apple Git-155)
reviewer Reviewed-by on v2 1/1
#1 lore raw
Quoted 8 lines · Pengpeng Hou

The sil,i2s-data-lanes property reader bounds the number of entries, but does not bound each entry's value. Those values index the four-entry i2s_lane_id table when the audio FIFO sequence is built.

Reject unsupported lane values before indexing that table. Report the property name and invalid value with dev_err_probe() so the diagnostic identifies the faulty configuration.

Quoted 5 lines

The issue was found by our static-analysis tool.

Fixes ff5781634c41 ("drm/bridge: sii902x: Implement HDMI audio support")
Assisted-by gpt 5

--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

reviewer Applied
#2 lore raw
In reply to Pengpeng Hou
Quoted 9 lines · Pengpeng Hou

The sil,i2s-data-lanes property reader bounds the number of entries, but does not bound each entry's value. Those values index the four-entry i2s_lane_id table when the audio FIFO sequence is built.

Reject unsupported lane values before indexing that table. Report the property name and invalid value with dev_err_probe() so the diagnostic identifies the faulty configuration.

[...]

Applied, thanks!

[1/1] drm/bridge: sii902x: validate I2S data lane values

      commit: 444b7116e7ef1fdb5f7db3bc1f74b20098d062d4

Best regards,

Signature · 3 lines
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com