linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 4.9/4.14/4.19/5.4] tty/serial: digicolor: fix possible null-ptr-deref in digicolor_uart_probe()
@ 2022-05-16 14:11 Yang Yingliang
  2022-05-16 15:26 ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Yang Yingliang @ 2022-05-16 14:11 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: baruch, gregkh

commit 447ee1516f19f534a228dda237eddb202f23e163 upstream.

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>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20220505124621.1592697-1-yangyingliang@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
v1:
  These stable versions don't have devm_platform_get_and_ioremap_resource(),
  so just move using 'res' after devm_ioremap_resource().
---
 drivers/tty/serial/digicolor-usart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/digicolor-usart.c b/drivers/tty/serial/digicolor-usart.c
index 50ec5f1ac77f4..794864fac6250 100644
--- a/drivers/tty/serial/digicolor-usart.c
+++ b/drivers/tty/serial/digicolor-usart.c
@@ -476,10 +476,10 @@ static int digicolor_uart_probe(struct platform_device *pdev)
 		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);
 	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

* Re: [PATCH 4.9/4.14/4.19/5.4] tty/serial: digicolor: fix possible null-ptr-deref in digicolor_uart_probe()
  2022-05-16 14:11 [PATCH 4.9/4.14/4.19/5.4] tty/serial: digicolor: fix possible null-ptr-deref in digicolor_uart_probe() Yang Yingliang
@ 2022-05-16 15:26 ` Greg KH
  0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2022-05-16 15:26 UTC (permalink / raw)
  To: Yang Yingliang; +Cc: linux-kernel, stable, baruch

On Mon, May 16, 2022 at 10:11:52PM +0800, Yang Yingliang wrote:
> commit 447ee1516f19f534a228dda237eddb202f23e163 upstream.
> 
> 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>
> Cc: stable <stable@vger.kernel.org>
> Link: https://lore.kernel.org/r/20220505124621.1592697-1-yangyingliang@huawei.com
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> v1:
>   These stable versions don't have devm_platform_get_and_ioremap_resource(),
>   so just move using 'res' after devm_ioremap_resource().
> ---
>  drivers/tty/serial/digicolor-usart.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/digicolor-usart.c b/drivers/tty/serial/digicolor-usart.c
> index 50ec5f1ac77f4..794864fac6250 100644
> --- a/drivers/tty/serial/digicolor-usart.c
> +++ b/drivers/tty/serial/digicolor-usart.c
> @@ -476,10 +476,10 @@ static int digicolor_uart_probe(struct platform_device *pdev)
>  		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);
>  	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
> 

Now queued up, thanks.

greg k-h

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

* [PATCH 4.9/4.14/4.19/5.4] tty/serial: digicolor: fix possible null-ptr-deref in digicolor_uart_probe()
@ 2022-05-16 14:10 Yang Yingliang
  2022-05-16 14:01 ` Yang Yingliang
  0 siblings, 1 reply; 4+ messages in thread
From: Yang Yingliang @ 2022-05-16 14:10 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: baruch, gregkh

commit 7c25a0b89a487878b0691e6524fb5a8827322194 upstream.

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>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20220505124621.1592697-1-yangyingliang@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
v1:
  These stable versions don't have devm_platform_get_and_ioremap_resource(),
  so just move using 'res' after devm_ioremap_resource().
---
 drivers/tty/serial/digicolor-usart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/digicolor-usart.c b/drivers/tty/serial/digicolor-usart.c
index 50ec5f1ac77f4..794864fac6250 100644
--- a/drivers/tty/serial/digicolor-usart.c
+++ b/drivers/tty/serial/digicolor-usart.c
@@ -476,10 +476,10 @@ static int digicolor_uart_probe(struct platform_device *pdev)
 		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);
 	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

* Re: [PATCH 4.9/4.14/4.19/5.4] tty/serial: digicolor: fix possible null-ptr-deref in digicolor_uart_probe()
  2022-05-16 14:10 Yang Yingliang
@ 2022-05-16 14:01 ` Yang Yingliang
  0 siblings, 0 replies; 4+ messages in thread
From: Yang Yingliang @ 2022-05-16 14:01 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: baruch, gregkh

I use a wrong commit id, please ignore this patch.

On 2022/5/16 22:10, Yang Yingliang wrote:
> commit 7c25a0b89a487878b0691e6524fb5a8827322194 upstream.
>
> 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>
> Cc: stable <stable@vger.kernel.org>
> Link: https://lore.kernel.org/r/20220505124621.1592697-1-yangyingliang@huawei.com
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> v1:
>    These stable versions don't have devm_platform_get_and_ioremap_resource(),
>    so just move using 'res' after devm_ioremap_resource().
> ---
>   drivers/tty/serial/digicolor-usart.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/digicolor-usart.c b/drivers/tty/serial/digicolor-usart.c
> index 50ec5f1ac77f4..794864fac6250 100644
> --- a/drivers/tty/serial/digicolor-usart.c
> +++ b/drivers/tty/serial/digicolor-usart.c
> @@ -476,10 +476,10 @@ static int digicolor_uart_probe(struct platform_device *pdev)
>   		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);
>   	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)

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

end of thread, other threads:[~2022-05-16 15:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-16 14:11 [PATCH 4.9/4.14/4.19/5.4] tty/serial: digicolor: fix possible null-ptr-deref in digicolor_uart_probe() Yang Yingliang
2022-05-16 15:26 ` Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2022-05-16 14:10 Yang Yingliang
2022-05-16 14:01 ` Yang Yingliang

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).