2022-05-01 15:58:44

by Shubhrajyoti Datta

[permalink] [raw]
Subject: [PATCH 3/7] tty: xilinx_uartps: Add check for runtime_get_sync calls

Add a check for the return value of runtime get_sync calls.

Addresses-Coverity: Event check_return.
Signed-off-by: Shubhrajyoti Datta <[email protected]>
---
drivers/tty/serial/xilinx_uartps.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c
index 8f15fe24a0eb..868f4e587263 100644
--- a/drivers/tty/serial/xilinx_uartps.c
+++ b/drivers/tty/serial/xilinx_uartps.c
@@ -1100,13 +1100,17 @@ static void cdns_uart_poll_put_char(struct uart_port *port, unsigned char c)
static void cdns_uart_pm(struct uart_port *port, unsigned int state,
unsigned int oldstate)
{
+ int ret;
+
switch (state) {
case UART_PM_STATE_OFF:
pm_runtime_mark_last_busy(port->dev);
pm_runtime_put_autosuspend(port->dev);
break;
default:
- pm_runtime_get_sync(port->dev);
+ ret = pm_runtime_get_sync(port->dev);
+ if (ret < 0)
+ dev_err(port->dev, "Failed to enable clocks\n");
break;
}
}
--
2.25.1


2022-05-06 21:45:16

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 3/7] tty: xilinx_uartps: Add check for runtime_get_sync calls

On Fri, Apr 29, 2022 at 01:44:18PM +0530, Shubhrajyoti Datta wrote:
> Add a check for the return value of runtime get_sync calls.
>
> Addresses-Coverity: Event check_return.
> Signed-off-by: Shubhrajyoti Datta <[email protected]>
> ---
> drivers/tty/serial/xilinx_uartps.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c
> index 8f15fe24a0eb..868f4e587263 100644
> --- a/drivers/tty/serial/xilinx_uartps.c
> +++ b/drivers/tty/serial/xilinx_uartps.c
> @@ -1100,13 +1100,17 @@ static void cdns_uart_poll_put_char(struct uart_port *port, unsigned char c)
> static void cdns_uart_pm(struct uart_port *port, unsigned int state,
> unsigned int oldstate)
> {
> + int ret;
> +
> switch (state) {
> case UART_PM_STATE_OFF:
> pm_runtime_mark_last_busy(port->dev);
> pm_runtime_put_autosuspend(port->dev);
> break;
> default:
> - pm_runtime_get_sync(port->dev);
> + ret = pm_runtime_get_sync(port->dev);
> + if (ret < 0)
> + dev_err(port->dev, "Failed to enable clocks\n");

So you just ignore the error? SHouldn't you propagate it back upward?

thanks,

greg k-h

2022-05-10 13:35:58

by Shubhrajyoti Datta

[permalink] [raw]
Subject: RE: [PATCH 3/7] tty: xilinx_uartps: Add check for runtime_get_sync calls



> -----Original Message-----
> From: Greg KH <[email protected]>
> Sent: Friday, May 6, 2022 2:21 AM
> To: Shubhrajyoti Datta <[email protected]>
> Cc: [email protected]; Michal Simek <[email protected]>;
> [email protected]; git <[email protected]>; [email protected]
> Subject: Re: [PATCH 3/7] tty: xilinx_uartps: Add check for runtime_get_sync calls
>
> On Fri, Apr 29, 2022 at 01:44:18PM +0530, Shubhrajyoti Datta wrote:
> > Add a check for the return value of runtime get_sync calls.
> >
> > Addresses-Coverity: Event check_return.
> > Signed-off-by: Shubhrajyoti Datta <[email protected]>
> > ---
> > drivers/tty/serial/xilinx_uartps.c | 6 +++++-
> > 1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/tty/serial/xilinx_uartps.c
> > b/drivers/tty/serial/xilinx_uartps.c
> > index 8f15fe24a0eb..868f4e587263 100644
> > --- a/drivers/tty/serial/xilinx_uartps.c
> > +++ b/drivers/tty/serial/xilinx_uartps.c
> > @@ -1100,13 +1100,17 @@ static void cdns_uart_poll_put_char(struct
> > uart_port *port, unsigned char c) static void cdns_uart_pm(struct uart_port
> *port, unsigned int state,
> > unsigned int oldstate)
> > {
> > + int ret;
> > +
> > switch (state) {
> > case UART_PM_STATE_OFF:
> > pm_runtime_mark_last_busy(port->dev);
> > pm_runtime_put_autosuspend(port->dev);
> > break;
> > default:
> > - pm_runtime_get_sync(port->dev);
> > + ret = pm_runtime_get_sync(port->dev);
> > + if (ret < 0)
> > + dev_err(port->dev, "Failed to enable clocks\n");
>
> So you just ignore the error? SHouldn't you propagate it back upward?

The cdns_uart_pm is void so we cannot propagate it upward.

>
> thanks,
>
> greg k-h