lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Thu, 23 Dec 2021 12:54:06 +0000
From:   Robin Murphy <robin.murphy@....com>
To:     Jiasheng Jiang <jiasheng@...as.ac.cn>, andy.shevchenko@...il.com,
        gregkh@...uxfoundation.org, jirislaby@...nel.org,
        liviu.dudau@....com, sudeep.holla@....com,
        lorenzo.pieralisi@....com
Cc:     linux-serial@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3] serial: mps2-uart: Check for error irq

On 2021-12-23 12:14, Jiasheng Jiang wrote:
> Because of the possible failure of the platform_get_irq(), it should be
> better to check it to avoid the use of error irq.

As far as I can see, the only "use" of error values is that they will be 
passed to request_irq(), which will then return -EINVAL because they are 
not valid IRQ numbers, and that error will be handled appropriately. I 
think that's a relatively common pattern, so your commit message should 
really describe why you think it's a problem and why this addition is a 
meaningful improvement.

Robin.

> Fixes: 041f031def33 ("serial: mps2-uart: add MPS2 UART driver")
> Signed-off-by: Jiasheng Jiang <jiasheng@...as.ac.cn>
> ---
> Changelog:
> 
> v2 -> v3
> 
> *Change 1. Using error variable to check.
> *Change 2. Add new commit message.
> ---
>   drivers/tty/serial/mps2-uart.c | 26 ++++++++++++++++++++++----
>   1 file changed, 22 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/tty/serial/mps2-uart.c b/drivers/tty/serial/mps2-uart.c
> index 587b42f754cb..24a52300d8d9 100644
> --- a/drivers/tty/serial/mps2-uart.c
> +++ b/drivers/tty/serial/mps2-uart.c
> @@ -584,11 +584,29 @@ static int mps2_init_port(struct platform_device *pdev,
>   
>   
>   	if (mps_port->flags & UART_PORT_COMBINED_IRQ) {
> -		mps_port->port.irq = platform_get_irq(pdev, 0);
> +		ret = platform_get_irq(pdev, 0);
> +		if (ret < 0)
> +			return ret;
> +
> +		mps_port->port.irq = ret;
>   	} else {
> -		mps_port->rx_irq = platform_get_irq(pdev, 0);
> -		mps_port->tx_irq = platform_get_irq(pdev, 1);
> -		mps_port->port.irq = platform_get_irq(pdev, 2);
> +		ret = platform_get_irq(pdev, 0);
> +		if (ret < 0)
> +			return ret;
> +
> +		mps_port->rx_irq = ret;
> +
> +		ret = platform_get_irq(pdev, 1);
> +		if (ret < 0)
> +			return ret;
> +
> +		mps_port->tx_irq = ret;
> +
> +		ret = platform_get_irq(pdev, 2);
> +		if (ret < 0)
> +			return ret;
> +
> +		mps_port->port.irq = ret;
>   	}
>   
>   	return ret;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ