* [PATCH v2] serial: samsung: Checks the return value of function
[not found] <CGME20210630133115epcas5p1706041f122819d47b18b83853b49694e@epcas5p1.samsung.com>
@ 2021-06-30 13:33 ` Tamseel Shams
2021-07-01 6:36 ` Krzysztof Kozlowski
0 siblings, 1 reply; 3+ messages in thread
From: Tamseel Shams @ 2021-06-30 13:33 UTC (permalink / raw)
To: krzysztof.kozlowski, gregkh, jirislaby
Cc: linux-arm-kernel, linux-samsung-soc, linux-serial, linux-kernel,
alim.akhtar, Tamseel Shams
"uart_add_one_port" function call may fail and return
some error code, so adding a check for return value.
If it is returning some error code, then displaying the
result, unregistering the driver and then returning from
probe function with error code.
Signed-off-by: Tamseel Shams <m.shams@samsung.com>
---
Changes since v1:
1. Added support to unregister driver on failure of "uart_add_onr_port"
function call.
2. Commit message updated.
drivers/tty/serial/samsung_tty.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c
index 9fbc61151c2e..188e2d2da201 100644
--- a/drivers/tty/serial/samsung_tty.c
+++ b/drivers/tty/serial/samsung_tty.c
@@ -2253,7 +2253,11 @@ static int s3c24xx_serial_probe(struct platform_device *pdev)
}
dev_dbg(&pdev->dev, "%s: adding port\n", __func__);
- uart_add_one_port(&s3c24xx_uart_drv, &ourport->port);
+ ret = uart_add_one_port(&s3c24xx_uart_drv, &ourport->port);
+ if (ret < 0) {
+ dev_err(&pdev->dev, "Failed to add uart port, err %d\n", ret);
+ goto add_port_error;
+ }
platform_set_drvdata(pdev, &ourport->port);
/*
@@ -2272,6 +2276,11 @@ static int s3c24xx_serial_probe(struct platform_device *pdev)
probe_index++;
return 0;
+
+add_port_error:
+ ourport->port.mapbase = 0;
+ uart_unregister_driver(&s3c24xx_uart_drv);
+ return ret;
}
static int s3c24xx_serial_remove(struct platform_device *dev)
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] serial: samsung: Checks the return value of function
2021-06-30 13:33 ` [PATCH v2] serial: samsung: Checks the return value of function Tamseel Shams
@ 2021-07-01 6:36 ` Krzysztof Kozlowski
2021-07-05 11:04 ` M Tamseel Shams
0 siblings, 1 reply; 3+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-01 6:36 UTC (permalink / raw)
To: Tamseel Shams, gregkh, jirislaby
Cc: linux-arm-kernel, linux-samsung-soc, linux-serial, linux-kernel,
alim.akhtar
On 30/06/2021 15:33, Tamseel Shams wrote:
> "uart_add_one_port" function call may fail and return
> some error code, so adding a check for return value.
> If it is returning some error code, then displaying the
> result, unregistering the driver and then returning from
> probe function with error code.
>
> Signed-off-by: Tamseel Shams <m.shams@samsung.com>
> ---
> Changes since v1:
> 1. Added support to unregister driver on failure of "uart_add_onr_port"
> function call.
> 2. Commit message updated.
>
> drivers/tty/serial/samsung_tty.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c
> index 9fbc61151c2e..188e2d2da201 100644
> --- a/drivers/tty/serial/samsung_tty.c
> +++ b/drivers/tty/serial/samsung_tty.c
> @@ -2253,7 +2253,11 @@ static int s3c24xx_serial_probe(struct platform_device *pdev)
> }
>
> dev_dbg(&pdev->dev, "%s: adding port\n", __func__);
> - uart_add_one_port(&s3c24xx_uart_drv, &ourport->port);
> + ret = uart_add_one_port(&s3c24xx_uart_drv, &ourport->port);
> + if (ret < 0) {
> + dev_err(&pdev->dev, "Failed to add uart port, err %d\n", ret);
> + goto add_port_error;
> + }
> platform_set_drvdata(pdev, &ourport->port);
>
> /*
> @@ -2272,6 +2276,11 @@ static int s3c24xx_serial_probe(struct platform_device *pdev)
> probe_index++;
>
> return 0;
> +
> +add_port_error:
You did not unwind fully s3c24xx_serial_init_port() - clocks.
> + ourport->port.mapbase = 0;
> + uart_unregister_driver(&s3c24xx_uart_drv);
> + return ret;
> }
>
> static int s3c24xx_serial_remove(struct platform_device *dev)
>
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH v2] serial: samsung: Checks the return value of function
2021-07-01 6:36 ` Krzysztof Kozlowski
@ 2021-07-05 11:04 ` M Tamseel Shams
0 siblings, 0 replies; 3+ messages in thread
From: M Tamseel Shams @ 2021-07-05 11:04 UTC (permalink / raw)
To: 'Krzysztof Kozlowski', gregkh, jirislaby
Cc: linux-arm-kernel, linux-samsung-soc, linux-serial, linux-kernel,
alim.akhtar
> -----Original Message-----
> From: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
> Sent: Thursday, July 1, 2021 12:06 PM
> To: Tamseel Shams <m.shams@samsung.com>; gregkh@linuxfoundation.org;
> jirislaby@kernel.org
> Cc: linux-arm-kernel@lists.infradead.org; linux-samsung-soc@vger.kernel.org;
> linux-serial@vger.kernel.org; linux-kernel@vger.kernel.org;
> alim.akhtar@samsung.com
> Subject: Re: [PATCH v2] serial: samsung: Checks the return value of function
>
> On 30/06/2021 15:33, Tamseel Shams wrote:
> > "uart_add_one_port" function call may fail and return some error code,
> > so adding a check for return value.
> > If it is returning some error code, then displaying the result,
> > unregistering the driver and then returning from probe function with
> > error code.
> >
> > Signed-off-by: Tamseel Shams <m.shams@samsung.com>
> > ---
> > Changes since v1:
> > 1. Added support to unregister driver on failure of "uart_add_onr_port"
> > function call.
> > 2. Commit message updated.
> >
> > drivers/tty/serial/samsung_tty.c | 11 ++++++++++-
> > 1 file changed, 10 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/tty/serial/samsung_tty.c
> > b/drivers/tty/serial/samsung_tty.c
> > index 9fbc61151c2e..188e2d2da201 100644
> > --- a/drivers/tty/serial/samsung_tty.c
> > +++ b/drivers/tty/serial/samsung_tty.c
> > @@ -2253,7 +2253,11 @@ static int s3c24xx_serial_probe(struct
> platform_device *pdev)
> > }
> >
> > dev_dbg(&pdev->dev, "%s: adding port\n", __func__);
> > - uart_add_one_port(&s3c24xx_uart_drv, &ourport->port);
> > + ret = uart_add_one_port(&s3c24xx_uart_drv, &ourport->port);
> > + if (ret < 0) {
> > + dev_err(&pdev->dev, "Failed to add uart port, err %d\n", ret);
> > + goto add_port_error;
> > + }
> > platform_set_drvdata(pdev, &ourport->port);
> >
> > /*
> > @@ -2272,6 +2276,11 @@ static int s3c24xx_serial_probe(struct
> platform_device *pdev)
> > probe_index++;
> >
> > return 0;
> > +
> > +add_port_error:
>
> You did not unwind fully s3c24xx_serial_init_port() - clocks.
>
Hi Krzysztof,
Yeah, missed the unwinding of clocks.
Will fix this in next version.
Thanks & Regards,
Tamseel Shams
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-07-05 12:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20210630133115epcas5p1706041f122819d47b18b83853b49694e@epcas5p1.samsung.com>
2021-06-30 13:33 ` [PATCH v2] serial: samsung: Checks the return value of function Tamseel Shams
2021-07-01 6:36 ` Krzysztof Kozlowski
2021-07-05 11:04 ` M Tamseel Shams
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).