* [PATCH] tty/serial: digicolor: fix possible null-ptr-deref in digicolor_uart_probe()
@ 2022-05-05 12:46 ` Yang Yingliang
0 siblings, 0 replies; 4+ messages in thread
From: Yang Yingliang @ 2022-05-05 12:46 UTC (permalink / raw)
To: linux-kernel, linux-arm-kernel, linux-serial; +Cc: gregkh, jirislaby, baruch
It will cause null-ptr-deref when using 'res', if platform_get_resource()
returns NULL, so move using 'res' after devm_ioremap_resource() that
will check it to avoid null-ptr-deref.
And use devm_platform_get_and_ioremap_resource() to simplify code.
Fixes: 5930cb3511df ("serial: driver for Conexant Digicolor USART")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
drivers/tty/serial/digicolor-usart.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/tty/serial/digicolor-usart.c b/drivers/tty/serial/digicolor-usart.c
index 6d70fea76bb3..e37a917b9dbb 100644
--- a/drivers/tty/serial/digicolor-usart.c
+++ b/drivers/tty/serial/digicolor-usart.c
@@ -471,11 +471,10 @@ static int digicolor_uart_probe(struct platform_device *pdev)
if (IS_ERR(uart_clk))
return PTR_ERR(uart_clk);
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- dp->port.mapbase = res->start;
- dp->port.membase = devm_ioremap_resource(&pdev->dev, res);
+ dp->port.membase = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(dp->port.membase))
return PTR_ERR(dp->port.membase);
+ dp->port.mapbase = res->start;
irq = platform_get_irq(pdev, 0);
if (irq < 0)
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] tty/serial: digicolor: fix possible null-ptr-deref in digicolor_uart_probe()
@ 2022-05-05 12:46 ` Yang Yingliang
0 siblings, 0 replies; 4+ messages in thread
From: Yang Yingliang @ 2022-05-05 12:46 UTC (permalink / raw)
To: linux-kernel, linux-arm-kernel, linux-serial; +Cc: gregkh, jirislaby, baruch
It will cause null-ptr-deref when using 'res', if platform_get_resource()
returns NULL, so move using 'res' after devm_ioremap_resource() that
will check it to avoid null-ptr-deref.
And use devm_platform_get_and_ioremap_resource() to simplify code.
Fixes: 5930cb3511df ("serial: driver for Conexant Digicolor USART")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
drivers/tty/serial/digicolor-usart.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/tty/serial/digicolor-usart.c b/drivers/tty/serial/digicolor-usart.c
index 6d70fea76bb3..e37a917b9dbb 100644
--- a/drivers/tty/serial/digicolor-usart.c
+++ b/drivers/tty/serial/digicolor-usart.c
@@ -471,11 +471,10 @@ static int digicolor_uart_probe(struct platform_device *pdev)
if (IS_ERR(uart_clk))
return PTR_ERR(uart_clk);
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- dp->port.mapbase = res->start;
- dp->port.membase = devm_ioremap_resource(&pdev->dev, res);
+ dp->port.membase = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(dp->port.membase))
return PTR_ERR(dp->port.membase);
+ dp->port.mapbase = res->start;
irq = platform_get_irq(pdev, 0);
if (irq < 0)
--
2.25.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] tty/serial: digicolor: fix possible null-ptr-deref in digicolor_uart_probe()
2022-05-05 12:46 ` Yang Yingliang
@ 2022-05-05 14:36 ` Baruch Siach
-1 siblings, 0 replies; 4+ messages in thread
From: Baruch Siach @ 2022-05-05 14:36 UTC (permalink / raw)
To: Yang Yingliang
Cc: linux-kernel, linux-arm-kernel, linux-serial, gregkh, jirislaby
Hi Yang,
On Thu, May 05 2022, Yang Yingliang wrote:
> It will cause null-ptr-deref when using 'res', if platform_get_resource()
> returns NULL, so move using 'res' after devm_ioremap_resource() that
> will check it to avoid null-ptr-deref.
> And use devm_platform_get_and_ioremap_resource() to simplify code.
>
> Fixes: 5930cb3511df ("serial: driver for Conexant Digicolor USART")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Baruch Siach <baruch@tkos.co.il>
Thanks,
baruch
> ---
> drivers/tty/serial/digicolor-usart.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/tty/serial/digicolor-usart.c b/drivers/tty/serial/digicolor-usart.c
> index 6d70fea76bb3..e37a917b9dbb 100644
> --- a/drivers/tty/serial/digicolor-usart.c
> +++ b/drivers/tty/serial/digicolor-usart.c
> @@ -471,11 +471,10 @@ static int digicolor_uart_probe(struct platform_device *pdev)
> if (IS_ERR(uart_clk))
> return PTR_ERR(uart_clk);
>
> - res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - dp->port.mapbase = res->start;
> - dp->port.membase = devm_ioremap_resource(&pdev->dev, res);
> + dp->port.membase = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
> if (IS_ERR(dp->port.membase))
> return PTR_ERR(dp->port.membase);
> + dp->port.mapbase = res->start;
>
> irq = platform_get_irq(pdev, 0);
> if (irq < 0)
--
~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tty/serial: digicolor: fix possible null-ptr-deref in digicolor_uart_probe()
@ 2022-05-05 14:36 ` Baruch Siach
0 siblings, 0 replies; 4+ messages in thread
From: Baruch Siach @ 2022-05-05 14:36 UTC (permalink / raw)
To: Yang Yingliang
Cc: linux-kernel, linux-arm-kernel, linux-serial, gregkh, jirislaby
Hi Yang,
On Thu, May 05 2022, Yang Yingliang wrote:
> It will cause null-ptr-deref when using 'res', if platform_get_resource()
> returns NULL, so move using 'res' after devm_ioremap_resource() that
> will check it to avoid null-ptr-deref.
> And use devm_platform_get_and_ioremap_resource() to simplify code.
>
> Fixes: 5930cb3511df ("serial: driver for Conexant Digicolor USART")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Baruch Siach <baruch@tkos.co.il>
Thanks,
baruch
> ---
> drivers/tty/serial/digicolor-usart.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/tty/serial/digicolor-usart.c b/drivers/tty/serial/digicolor-usart.c
> index 6d70fea76bb3..e37a917b9dbb 100644
> --- a/drivers/tty/serial/digicolor-usart.c
> +++ b/drivers/tty/serial/digicolor-usart.c
> @@ -471,11 +471,10 @@ static int digicolor_uart_probe(struct platform_device *pdev)
> if (IS_ERR(uart_clk))
> return PTR_ERR(uart_clk);
>
> - res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - dp->port.mapbase = res->start;
> - dp->port.membase = devm_ioremap_resource(&pdev->dev, res);
> + dp->port.membase = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
> if (IS_ERR(dp->port.membase))
> return PTR_ERR(dp->port.membase);
> + dp->port.mapbase = res->start;
>
> irq = platform_get_irq(pdev, 0);
> if (irq < 0)
--
~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-05-05 14:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-05 12:46 [PATCH] tty/serial: digicolor: fix possible null-ptr-deref in digicolor_uart_probe() Yang Yingliang
2022-05-05 12:46 ` Yang Yingliang
2022-05-05 14:36 ` Baruch Siach
2022-05-05 14:36 ` Baruch Siach
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.