Skip to contentSkip to conversation

serial: liteuart: fix missing drvdata

PATCH In review Ilia Sergachev 2 participants 2 messages Nov 15, 2021

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

PATCH v2 1/1 serial: liteuart: fix missing drvdata

drvdata has to be set in _probe() - otherwise platform_get_drvdata() causes null pointer dereference BUG in _remove()

Fixes 1da81e5562fa ("drivers/tty/serial: add LiteUART driver")

---
v1 -> v2: add Fixes:

 drivers/tty/serial/liteuart.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/tty/serial/liteuart.c +2 -0
index dbc0559a9157..f075f4ff5fcf 100644
@@ -285,6 +285,8 @@ static int liteuart_probe(struct platform_device *pdev)
 	port->line = dev_id;
 	spin_lock_init(&port->lock);
 
+	platform_set_drvdata(pdev, port);
+
 	return uart_add_one_port(&liteuart_driver, &uart->port);
 }
 
Signature · 1 line
2.25.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 16 lines · Ilia Sergachev

drvdata has to be set in _probe() - otherwise platform_get_drvdata() causes null pointer dereference BUG in _remove()

Fixes 1da81e5562fa ("drivers/tty/serial: add LiteUART driver")

---
v1 -> v2: add Fixes:

 drivers/tty/serial/liteuart.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/tty/serial/liteuart.c +0 -0
index dbc0559a9157..f075f4ff5fcf 100644

drivers/tty/serial/liteuart.c static int liteuart_probe(struct platform_device *pdev) · line 291

Quoted 7 lines
drivers/tty/serial/liteuart.c +2 -0
@@ -285,6 +285,8 @@ static int liteuart_probe(struct platform_device *pdev)
 	port->line = dev_id;
 	spin_lock_init(&port->lock);
 
+	platform_set_drvdata(pdev, port);
+
 	return uart_add_one_port(&liteuart_driver, &uart->port);
 }

Looks good:

There are more issues with driver unbind than this though as the port is never deregistered. I've fixed it up on top of this patch:

	https://lore.kernel.org/r/[email protected]

Johan