diff mbox series

[v2] serial: st-asc: Fix to check return value of platform_get_irq() in asc_init_port()

Message ID tencent_7E9B9A5A97AD3B30550F1A8553D44F09C607@qq.com
State New
Headers show
Series [v2] serial: st-asc: Fix to check return value of platform_get_irq() in asc_init_port() | expand

Commit Message

Zhang Shurong Aug. 26, 2023, 7:54 a.m. UTC
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: c4b058560762 ("serial:st-asc: Add ST ASC driver.")
Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
---
v1->v2: generated patch based on tty-next tree.

 drivers/tty/serial/st-asc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Greg Kroah-Hartman Sept. 18, 2023, 7:55 a.m. UTC | #1
On Sat, Aug 26, 2023 at 03:54:59PM +0800, Zhang Shurong wrote:
> 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: c4b058560762 ("serial:st-asc: Add ST ASC driver.")
> Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
> ---
> v1->v2: generated patch based on tty-next tree.
> 
>  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 e7048515a79c..3d60ab6e9581 100644
> --- a/drivers/tty/serial/st-asc.c
> +++ b/drivers/tty/serial/st-asc.c
> @@ -723,9 +723,13 @@ static int asc_init_port(struct asc_port *ascport,
>  	port->ops	= &asc_uart_ops;
>  	port->fifosize	= ASC_FIFO_SIZE;
>  	port->dev	= &pdev->dev;
> -	port->irq	= platform_get_irq(pdev, 0);
>  	port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_ST_ASC_CONSOLE);
>  
> +	ret = platform_get_irq(pdev, 0);
> +	if (ret < 0)
> +		return ret;
> +	port->irq = ret;
> +
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	port->membase = devm_ioremap_resource(&pdev->dev, res);
>  	if (IS_ERR(port->membase))
> -- 
> 2.30.2
> 

Does not apply to 6.6-rc2 :(
diff mbox series

Patch

diff --git a/drivers/tty/serial/st-asc.c b/drivers/tty/serial/st-asc.c
index e7048515a79c..3d60ab6e9581 100644
--- a/drivers/tty/serial/st-asc.c
+++ b/drivers/tty/serial/st-asc.c
@@ -723,9 +723,13 @@  static int asc_init_port(struct asc_port *ascport,
 	port->ops	= &asc_uart_ops;
 	port->fifosize	= ASC_FIFO_SIZE;
 	port->dev	= &pdev->dev;
-	port->irq	= platform_get_irq(pdev, 0);
 	port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_ST_ASC_CONSOLE);
 
+	ret = platform_get_irq(pdev, 0);
+	if (ret < 0)
+		return ret;
+	port->irq = ret;
+
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	port->membase = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(port->membase))