[PATCH] serial: st-asc: Check return value of platform_get_irq() in asc_init_port()
Jiri Slaby
jirislaby at kernel.org
Wed Oct 18 22:02:32 PDT 2023
On 18. 10. 23, 20:28, Hugo Villeneuve wrote:
> On Wed, 18 Oct 2023 09:12:40 +0000
> Yi Yang <yiyang13 at huawei.com> wrote:
>
>> The platform_get_irq() might be failed and return a negative result, there
>> should be return an error code when platform_get_irq() failed.
>> Fix it by add check return value of platform_get_irq().
>>
>> Fixes: c4b058560762 ("serial:st-asc: Add ST ASC driver.")
>> Signed-off-by: Yi Yang <yiyang13 at huawei.com>
>> ---
>> drivers/tty/serial/st-asc.c | 6 +++++-
>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/tty/serial/st-asc.c b/drivers/tty/serial/st-asc.c
>> index a821f5d76a26..8321167502dc 100644
>> --- a/drivers/tty/serial/st-asc.c
>> +++ b/drivers/tty/serial/st-asc.c
>> @@ -683,12 +683,16 @@ static int asc_init_port(struct asc_port *ascport,
>> struct resource *res;
>> int ret;
>>
>> + ret = platform_get_irq(pdev, 0);
>
> Hi,
> for readability, you could define a new irq variable instead of using
> ret. See reasoning below.
>
>> + if (ret < 0)
>> + return ret;
>> +
>> port->iotype = UPIO_MEM;
>> port->flags = UPF_BOOT_AUTOCONF;
>> port->ops = &asc_uart_ops;
>> port->fifosize = ASC_FIFO_SIZE;
>> port->dev = &pdev->dev;
>> - port->irq = platform_get_irq(pdev, 0);
>> + port->irq = ret;
>
> Assigning port->irq to irq instead of ret will make the code more
> understandable.
Yes. And you need not to worry that someone will stick another
ret = something();
after platform_get_irq() above.
thanks,
--
js
suse labs
More information about the linux-arm-kernel
mailing list