linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tty: serial: add missing clk_put()
       [not found] <20230718075401.16668-1-xujianghui@cdjrlc.com>
@ 2023-07-18  7:55 ` sunran001
  2023-07-18  8:40   ` Dmitry Baryshkov
  2023-07-18 13:25   ` Greg KH
  0 siblings, 2 replies; 3+ messages in thread
From: sunran001 @ 2023-07-18  7:55 UTC (permalink / raw)
  To: gregkh; +Cc: linux-serial, linux-kernel

This patch fixes the following Coccinelle error:

./drivers/tty/serial/bcm63xx_uart.c:854:2-8: ERROR: missing clk_put;
clk_get on line 849 and execution via conditional on line 853

Signed-off-by: Ran Sun <sunran001@208suo.com>
---
  drivers/tty/serial/bcm63xx_uart.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/drivers/tty/serial/bcm63xx_uart.c 
b/drivers/tty/serial/bcm63xx_uart.c
index 55e82d0bf92d..7353b683952d 100644
--- a/drivers/tty/serial/bcm63xx_uart.c
+++ b/drivers/tty/serial/bcm63xx_uart.c
@@ -851,6 +851,7 @@ static int bcm_uart_probe(struct platform_device 
*pdev)
          clk = of_clk_get(pdev->dev.of_node, 0);

      if (IS_ERR(clk))
+        clk_put(clk);
          return -ENODEV;

      port->iotype = UPIO_MEM;

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] tty: serial: add missing clk_put()
  2023-07-18  7:55 ` [PATCH] tty: serial: add missing clk_put() sunran001
@ 2023-07-18  8:40   ` Dmitry Baryshkov
  2023-07-18 13:25   ` Greg KH
  1 sibling, 0 replies; 3+ messages in thread
From: Dmitry Baryshkov @ 2023-07-18  8:40 UTC (permalink / raw)
  To: sunran001, gregkh; +Cc: linux-serial, linux-kernel

On 18/07/2023 10:55, sunran001@208suo.com wrote:
> This patch fixes the following Coccinelle error:
> 
> ./drivers/tty/serial/bcm63xx_uart.c:854:2-8: ERROR: missing clk_put;
> clk_get on line 849 and execution via conditional on line 853
> 
> Signed-off-by: Ran Sun <sunran001@208suo.com>
> ---
>   drivers/tty/serial/bcm63xx_uart.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/tty/serial/bcm63xx_uart.c 
> b/drivers/tty/serial/bcm63xx_uart.c
> index 55e82d0bf92d..7353b683952d 100644
> --- a/drivers/tty/serial/bcm63xx_uart.c
> +++ b/drivers/tty/serial/bcm63xx_uart.c
> @@ -851,6 +851,7 @@ static int bcm_uart_probe(struct platform_device *pdev)
>           clk = of_clk_get(pdev->dev.of_node, 0);
> 
>       if (IS_ERR(clk))
> +        clk_put(clk);

No!

First, calling clk_put() on the error pointer is incorrect. This will 
throw a warning in __clk_put(), but generally passing an error pointer 
to another function can cause different kinds of breakage.

Second, you have added the line, but this also moved the return 
statement out of the if condition. This way all bcm_uart_probe() calls 
will end up with -ENODEV return value.

Please stop blindly fixing the coccinelle warnings. Take care to read 
and understand the code.

>           return -ENODEV;
> 
>       port->iotype = UPIO_MEM;

-- 
With best wishes
Dmitry


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] tty: serial: add missing clk_put()
  2023-07-18  7:55 ` [PATCH] tty: serial: add missing clk_put() sunran001
  2023-07-18  8:40   ` Dmitry Baryshkov
@ 2023-07-18 13:25   ` Greg KH
  1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2023-07-18 13:25 UTC (permalink / raw)
  To: sunran001; +Cc: linux-serial, linux-kernel

On Tue, Jul 18, 2023 at 03:55:23PM +0800, sunran001@208suo.com wrote:
> This patch fixes the following Coccinelle error:
> 
> ./drivers/tty/serial/bcm63xx_uart.c:854:2-8: ERROR: missing clk_put;
> clk_get on line 849 and execution via conditional on line 853
> 
> Signed-off-by: Ran Sun <sunran001@208suo.com>
> ---
>  drivers/tty/serial/bcm63xx_uart.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/tty/serial/bcm63xx_uart.c
> b/drivers/tty/serial/bcm63xx_uart.c
> index 55e82d0bf92d..7353b683952d 100644
> --- a/drivers/tty/serial/bcm63xx_uart.c
> +++ b/drivers/tty/serial/bcm63xx_uart.c
> @@ -851,6 +851,7 @@ static int bcm_uart_probe(struct platform_device *pdev)
>          clk = of_clk_get(pdev->dev.of_node, 0);
> 
>      if (IS_ERR(clk))
> +        clk_put(clk);
>          return -ENODEV;
> 
>      port->iotype = UPIO_MEM;

Ran, as was pointed out before, you obviously didn't even test this
patch, nor any of the other submissions you made.

Please take the time to learn C a bit better, and then start out in a
part of the kernel where basic changes are accepted, like
drivers/staging/ so that you can learn how to properly send patches
(this was incorrectly sent as well.)

Then you can work up to attempting to fix other changes like this, if
they are correct, and you will know how to properly test your changes
instead of just making rote changes like this without understanding the
implications of them.

best of luck!

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-07-18 13:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20230718075401.16668-1-xujianghui@cdjrlc.com>
2023-07-18  7:55 ` [PATCH] tty: serial: add missing clk_put() sunran001
2023-07-18  8:40   ` Dmitry Baryshkov
2023-07-18 13:25   ` Greg KH

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).