* [PATCH][serial-next] serial-uartlite: fix null pointer dereference on pointer port
@ 2018-11-13 9:38 Colin King
2018-11-13 9:39 ` NACK: " Colin Ian King
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2018-11-13 9:38 UTC (permalink / raw)
To: Peter Korsgaard, Greg Kroah-Hartman, Jiri Slaby, linux-serial
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Pointer port is dereferenced on port->private_data when assigning pointer
pdata before port is null checked, leading to a potential null pointer
dereference. Fix this by assigning pdata after the null pointer check on
port.
Detected by CoverityScan, CID#1475434 ("Dereference before null check")
Fixes: 3b209d253e7f ("serial-uartlite: Do not use static struct uart_driver out of probe()")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/tty/serial/uartlite.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c
index 4a7989df5ff5..0eff33cd9f24 100644
--- a/drivers/tty/serial/uartlite.c
+++ b/drivers/tty/serial/uartlite.c
@@ -715,10 +715,12 @@ static int ulite_release(struct device *dev)
static int __maybe_unused ulite_suspend(struct device *dev)
{
struct uart_port *port = dev_get_drvdata(dev);
- struct uartlite_data *pdata = port->private_data;
- if (port)
+ if (port) {
+ struct uartlite_data *pdata = port->private_data;
+
uart_suspend_port(pdata->ulite_uart_driver, port);
+ }
return 0;
}
--
2.19.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* NACK: [PATCH][serial-next] serial-uartlite: fix null pointer dereference on pointer port
2018-11-13 9:38 [PATCH][serial-next] serial-uartlite: fix null pointer dereference on pointer port Colin King
@ 2018-11-13 9:39 ` Colin Ian King
0 siblings, 0 replies; 2+ messages in thread
From: Colin Ian King @ 2018-11-13 9:39 UTC (permalink / raw)
To: Peter Korsgaard, Greg Kroah-Hartman, Jiri Slaby, linux-serial
Cc: kernel-janitors, linux-kernel
On 13/11/2018 09:38, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Pointer port is dereferenced on port->private_data when assigning pointer
> pdata before port is null checked, leading to a potential null pointer
> dereference. Fix this by assigning pdata after the null pointer check on
> port.
>
> Detected by CoverityScan, CID#1475434 ("Dereference before null check")
>
> Fixes: 3b209d253e7f ("serial-uartlite: Do not use static struct uart_driver out of probe()")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/tty/serial/uartlite.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c
> index 4a7989df5ff5..0eff33cd9f24 100644
> --- a/drivers/tty/serial/uartlite.c
> +++ b/drivers/tty/serial/uartlite.c
> @@ -715,10 +715,12 @@ static int ulite_release(struct device *dev)
> static int __maybe_unused ulite_suspend(struct device *dev)
> {
> struct uart_port *port = dev_get_drvdata(dev);
> - struct uartlite_data *pdata = port->private_data;
>
> - if (port)
> + if (port) {
> + struct uartlite_data *pdata = port->private_data;
> +
> uart_suspend_port(pdata->ulite_uart_driver, port);
> + }
>
> return 0;
> }
>
Sorry for the noise, I sent the wrong fix. V2 coming soon.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-11-13 9:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-13 9:38 [PATCH][serial-next] serial-uartlite: fix null pointer dereference on pointer port Colin King
2018-11-13 9:39 ` NACK: " Colin Ian King
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).