[PATCH] tty: serial: linflexuart: Fix to check return value of platform_get_irq() in linflex_probe()

From: Zhang Shurong
Date: Sat Aug 26 2023 - 05:33:41 EST


The platform_get_irq might be failed and return a negative result. So
there should have an error handling code.

Fixed this by adding an error handling code.

Fixes: 09864c1cdf5c ("tty: serial: Add linflexuart driver for S32V234.")
Signed-off-by: Zhang Shurong <zhang_shurong@xxxxxxxxxxx>
---
drivers/tty/serial/fsl_linflexuart.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/fsl_linflexuart.c b/drivers/tty/serial/fsl_linflexuart.c
index 3e28be402aef..7a7461543bb4 100644
--- a/drivers/tty/serial/fsl_linflexuart.c
+++ b/drivers/tty/serial/fsl_linflexuart.c
@@ -850,10 +850,14 @@ static int linflex_probe(struct platform_device *pdev)
if (IS_ERR(sport->membase))
return PTR_ERR(sport->membase);

+ ret = platform_get_irq(pdev, 0);
+ if (ret < 0)
+ return ret;
+
sport->dev = &pdev->dev;
sport->type = PORT_LINFLEXUART;
sport->iotype = UPIO_MEM;
- sport->irq = platform_get_irq(pdev, 0);
+ sport->irq = ret;
sport->ops = &linflex_pops;
sport->flags = UPF_BOOT_AUTOCONF;
sport->has_sysrq = IS_ENABLED(CONFIG_SERIAL_FSL_LINFLEXUART_CONSOLE);
--
2.30.2