public inbox for linux-serial@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] serial: liteuart: fix missing drvdata
@ 2021-11-15  9:54 Ilia Sergachev
  2021-11-15 13:49 ` Johan Hovold
  0 siblings, 1 reply; 2+ messages in thread
From: Ilia Sergachev @ 2021-11-15  9:54 UTC (permalink / raw)
  To: linux-serial
  Cc: Karol Gugala, Mateusz Holenko, Jiri Slaby, Greg Kroah-Hartman,
	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")
Signed-off-by: Ilia Sergachev <silia@ethz.ch>
---
v1 -> v2: add Fixes:

 drivers/tty/serial/liteuart.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/tty/serial/liteuart.c b/drivers/tty/serial/liteuart.c
index dbc0559a9157..f075f4ff5fcf 100644
--- a/drivers/tty/serial/liteuart.c
+++ b/drivers/tty/serial/liteuart.c
@@ -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);
 }
 
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] serial: liteuart: fix missing drvdata
  2021-11-15  9:54 [PATCH v2] serial: liteuart: fix missing drvdata Ilia Sergachev
@ 2021-11-15 13:49 ` Johan Hovold
  0 siblings, 0 replies; 2+ messages in thread
From: Johan Hovold @ 2021-11-15 13:49 UTC (permalink / raw)
  To: Ilia Sergachev
  Cc: linux-serial, Karol Gugala, Mateusz Holenko, Jiri Slaby,
	Greg Kroah-Hartman

On Mon, Nov 15, 2021 at 10:54:58AM +0100, Ilia Sergachev wrote:
> 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")
> Signed-off-by: Ilia Sergachev <silia@ethz.ch>
> ---
> v1 -> v2: add Fixes:
> 
>  drivers/tty/serial/liteuart.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/tty/serial/liteuart.c b/drivers/tty/serial/liteuart.c
> index dbc0559a9157..f075f4ff5fcf 100644
> --- a/drivers/tty/serial/liteuart.c
> +++ b/drivers/tty/serial/liteuart.c
> @@ -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:

Reviewed-by: Johan Hovold <johan@kernel.org>

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/20211115133745.11445-1-johan@kernel.org

Johan

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-11-15 13:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-15  9:54 [PATCH v2] serial: liteuart: fix missing drvdata Ilia Sergachev
2021-11-15 13:49 ` Johan Hovold

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox