Skip to contentSkip to conversation

serial: mvebu-uart: drop of_match_ptr for ID table

PATCH Superseded Bramuel Barack 2 participants 2 messages Nov 15

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 serial: mvebu-uart: drop of_match_ptr for ID table

mvebu_uart_of_match[] is always compiled in and already referenced directly in mvebu_uart_probe(). Wrapping it in of_match_ptr() in mvebu_uart_platform_driver is redundant and prevents ACPI PRP0001 matching when CONFIG_OF is disabled.

Drop of_match_ptr() to reference the table directly.

---
 drivers/tty/serial/mvebu-uart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/mvebu-uart.c +1 -1
index 33ea496c93b2..8311e4c244f3 100644
@@ -1016,7 +1016,7 @@ static struct platform_driver mvebu_uart_platform_driver = {
 	.probe	= mvebu_uart_probe,
 	.driver	= {
 		.name  = "mvebu-uart",
-		.of_match_table = of_match_ptr(mvebu_uart_of_match),
+		.of_match_table = mvebu_uart_of_match,
 		.suppress_bind_attrs = true,
 #if defined(CONFIG_PM)
 		.pm	= &mvebu_uart_pm_ops,
Signature · 1 line
2.56.1
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] serial: mvebu-uart: NULL dereference in mvebu_uart_probe() on PRP0001 match --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] serial: mvebu-uart: NULL dereference in mvebu_uart_probe() on PRP0001 match
--

commit 3010b076c87d51f51ddcc431e71fb7901421ff0f
Author: Bramuel Barack <[email protected]>

serial: mvebu-uart: drop of_match_ptr for ID table

This commit removes the of_match_ptr() wrapper around mvebu_uart_of_match in mvebu_uart_platform_driver.

drivers/tty/serial/mvebu-uart.c static struct platform_driver mvebu_uart_platform_driver = { · line 1018

Quoted 10 lines
drivers/tty/serial/mvebu-uart.c +1 -1
index 8a61517d81f21..4026f4c0bf2cf 100644
@@ -1015,7 +1015,7 @@ static struct platform_driver mvebu_uart_platform_driver = {
 	.probe	= mvebu_uart_probe,
 	.driver	= {
 		.name  = "mvebu-uart",
-		.of_match_table = of_match_ptr(mvebu_uart_of_match),
+		.of_match_table = mvebu_uart_of_match,

[Severity: Medium]
Can this cause a NULL pointer dereference in mvebu_uart_probe() when a device matches via ACPI PRP0001?

drivers/tty/serial/mvebu-uart.c:mvebu_uart_probe() {
	...
	const struct of_device_id *match = of_match_device(mvebu_uart_of_match,
							   &pdev->dev);
	...
	mvuart->data = (struct mvebu_uart_driver_data *)match->data;
	...
}

When a device binds via ACPI PRP0001 (or when CONFIG_OF is disabled), of_match_device() returns NULL because pdev->dev.of_node is NULL, and mvebu_uart_probe() then unconditionally dereferences match->data. Using device_get_match_data(&pdev->dev) would support both DT and ACPI PRP0001 matching.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1