* [PATCH] serial: lantiq: store and compare return status correctly
@ 2021-12-21 18:41 Muhammad Usama Anjum
2021-12-22 13:38 ` Rob Herring
0 siblings, 1 reply; 2+ messages in thread
From: Muhammad Usama Anjum @ 2021-12-21 18:41 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, Rob Herring,
open list:SERIAL DRIVERS, open list, kernel
Cc: 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 <usama.anjum@collabora.com>
---
drivers/tty/serial/lantiq.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/drivers/tty/serial/lantiq.c b/drivers/tty/serial/lantiq.c
index bb059418cb82..3e324d3f0a6d 100644
--- a/drivers/tty/serial/lantiq.c
+++ b/drivers/tty/serial/lantiq.c
@@ -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;
--
2.30.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] serial: lantiq: store and compare return status correctly
2021-12-21 18:41 [PATCH] serial: lantiq: store and compare return status correctly Muhammad Usama Anjum
@ 2021-12-22 13:38 ` Rob Herring
0 siblings, 0 replies; 2+ messages in thread
From: Rob Herring @ 2021-12-22 13:38 UTC (permalink / raw)
To: Muhammad Usama Anjum
Cc: Greg Kroah-Hartman, Jiri Slaby, open list:SERIAL DRIVERS,
open list, Collabora Kernel ML
On Tue, Dec 21, 2021 at 2:42 PM Muhammad Usama Anjum
<usama.anjum@collabora.com> wrote:
>
> 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 <usama.anjum@collabora.com>
> ---
> drivers/tty/serial/lantiq.c | 24 ++++++++++++++----------
> 1 file changed, 14 insertions(+), 10 deletions(-)
Thanks for fixing this.
Acked-by: Rob Herring <robh@kernel.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-12-22 13:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-21 18:41 [PATCH] serial: lantiq: store and compare return status correctly Muhammad Usama Anjum
2021-12-22 13:38 ` Rob Herring
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).