serial: lantiq: store and compare return status correctly
PATCH 1/1 serial: lantiq: store and compare return status correctly
platform_get_irq() returns signed status. It should be stored and compared as signed value before storing to unsigned variable. Implicit conversion from signed to unsigned and then comparison with less than zero is wrong as unsigned value can never be less than zero.
Fixes f087f01ca2 ("serial: lantiq: Use platform_get_irq() to get the interrupt")
Signed-off-by Muhammad Usama Anjum <[email protected]>
--- drivers/tty/serial/lantiq.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)
drivers/tty/serial/lantiq.c +14 -10
@@ -727,16 +727,20 @@ static int fetch_irq_lantiq(struct device *dev, struct ltq_uart_port *ltq_port) {struct uart_port *port = <q_port->port;struct platform_device *pdev =to_platform_device (dev); - - ltq_port->tx_irq =platform_get_irq (pdev,0 ); -if (ltq_port->tx_irq <0 ) -return ltq_port->tx_irq; - ltq_port->rx_irq =platform_get_irq (pdev,1 ); -if (ltq_port->rx_irq <0 ) -return ltq_port->rx_irq; - ltq_port->err_irq =platform_get_irq (pdev,2 ); -if (ltq_port->err_irq <0 ) -return ltq_port->err_irq; +int irq; + + irq =platform_get_irq (pdev,0 ); +if (irq <0 ) +return irq; + ltq_port->tx_irq = irq; + irq =platform_get_irq (pdev,1 ); +if (irq <0 ) +return irq; + ltq_port->rx_irq = irq; + irq =platform_get_irq (pdev,2 ); +if (irq <0 ) +return irq; + ltq_port->err_irq = irq; port->irq = ltq_port->tx_irq;
Signature · 1 line
2.30.2
Quoted 11 lines · Muhammad Usama Anjum
platform_get_irq()returns signed status. It should be stored and compared as signed value before storing to unsigned variable. Implicit conversion from signed to unsigned and then comparison with less than zero is wrong as unsigned value can never be less than zero.Fixes f087f01ca2 ("serial: lantiq: Use platform_get_irq() to get the interrupt")Signed-off-by Muhammad Usama Anjum <[email protected]>--- drivers/tty/serial/lantiq.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)
Thanks for fixing this.
Acked-by Rob Herring <[email protected]>