From: Muhammad Usama Anjum <usama.anjum@collabora.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jirislaby@kernel.org>, Rob Herring <robh@kernel.org>,
"open list:SERIAL DRIVERS" <linux-serial@vger.kernel.org>,
open list <linux-kernel@vger.kernel.org>,
kernel@collabora.com
Cc: usama.anjum@collabora.com
Subject: [PATCH] serial: lantiq: store and compare return status correctly
Date: Tue, 21 Dec 2021 23:41:51 +0500 [thread overview]
Message-ID: <YcIf7+oSWWn34ND6@debian-BULLSEYE-live-builder-AMD64> (raw)
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
next reply other threads:[~2021-12-21 18:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-21 18:41 Muhammad Usama Anjum [this message]
2021-12-22 13:38 ` [PATCH] serial: lantiq: store and compare return status correctly Rob Herring
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=YcIf7+oSWWn34ND6@debian-BULLSEYE-live-builder-AMD64 \
--to=usama.anjum@collabora.com \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=kernel@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=robh@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox