serial: mvebu-uart: drop of_match_ptr for ID table
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
@@ -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
[email protected]
AI reviewThank 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@@ -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