All of lore.kernel.org
 help / color / mirror / Atom feed
From: Baruch Siach <baruch@tkos.co.il>
To: Yang Yingliang <yangyingliang@huawei.com>
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-serial@vger.kernel.org, gregkh@linuxfoundation.org,
	jirislaby@kernel.org
Subject: Re: [PATCH] tty/serial: digicolor: fix possible null-ptr-deref in digicolor_uart_probe()
Date: Thu, 05 May 2022 17:36:36 +0300	[thread overview]
Message-ID: <87h764hwow.fsf@tarshish> (raw)
In-Reply-To: <20220505124621.1592697-1-yangyingliang@huawei.com>

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 -

WARNING: multiple messages have this Message-ID (diff)
From: Baruch Siach <baruch@tkos.co.il>
To: Yang Yingliang <yangyingliang@huawei.com>
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-serial@vger.kernel.org, gregkh@linuxfoundation.org,
	jirislaby@kernel.org
Subject: Re: [PATCH] tty/serial: digicolor: fix possible null-ptr-deref in digicolor_uart_probe()
Date: Thu, 05 May 2022 17:36:36 +0300	[thread overview]
Message-ID: <87h764hwow.fsf@tarshish> (raw)
In-Reply-To: <20220505124621.1592697-1-yangyingliang@huawei.com>

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

  reply	other threads:[~2022-05-05 14:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2022-05-05 14:36   ` Baruch Siach

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h764hwow.fsf@tarshish \
    --to=baruch@tkos.co.il \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=yangyingliang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.