All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next] drivers/tty/serial: Add missing clk_disable_unprepare()
@ 2022-06-17  2:58 ` Guo Mengqi
  0 siblings, 0 replies; 14+ messages in thread
From: Guo Mengqi @ 2022-06-17  2:58 UTC (permalink / raw)
  To: gregkh, jirislaby, f.fainelli, rjui, sbranden,
	bcm-kernel-feedback-list, nsaenz, athierry, linux-serial,
	linux-rpi-kernel, linux-arm-kernel, linux-kernel
  Cc: xuqiang36

Add missing clk_disable_unprepare() when get clk rate fails.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Guo Mengqi <guomengqi3@huawei.com>
---
 drivers/tty/serial/8250/8250_bcm2835aux.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_bcm2835aux.c b/drivers/tty/serial/8250/8250_bcm2835aux.c
index 2a1226a78a0c..21939bb44613 100644
--- a/drivers/tty/serial/8250/8250_bcm2835aux.c
+++ b/drivers/tty/serial/8250/8250_bcm2835aux.c
@@ -166,8 +166,10 @@ static int bcm2835aux_serial_probe(struct platform_device *pdev)
 	uartclk = clk_get_rate(data->clk);
 	if (!uartclk) {
 		ret = device_property_read_u32(&pdev->dev, "clock-frequency", &uartclk);
-		if (ret)
-			return dev_err_probe(&pdev->dev, ret, "could not get clk rate\n");
+		if (ret) {
+			dev_err_probe(&pdev->dev, ret, "could not get clk rate\n");
+			goto dis_clk;
+		}
 	}
 
 	/* the HW-clock divider for bcm2835aux is 8,
-- 
2.17.1


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

* [PATCH -next] drivers/tty/serial: Add missing clk_disable_unprepare()
@ 2022-06-17  2:58 ` Guo Mengqi
  0 siblings, 0 replies; 14+ messages in thread
From: Guo Mengqi @ 2022-06-17  2:58 UTC (permalink / raw)
  To: gregkh, jirislaby, f.fainelli, rjui, sbranden,
	bcm-kernel-feedback-list, nsaenz, athierry, linux-serial,
	linux-rpi-kernel, linux-arm-kernel, linux-kernel
  Cc: xuqiang36

Add missing clk_disable_unprepare() when get clk rate fails.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Guo Mengqi <guomengqi3@huawei.com>
---
 drivers/tty/serial/8250/8250_bcm2835aux.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_bcm2835aux.c b/drivers/tty/serial/8250/8250_bcm2835aux.c
index 2a1226a78a0c..21939bb44613 100644
--- a/drivers/tty/serial/8250/8250_bcm2835aux.c
+++ b/drivers/tty/serial/8250/8250_bcm2835aux.c
@@ -166,8 +166,10 @@ static int bcm2835aux_serial_probe(struct platform_device *pdev)
 	uartclk = clk_get_rate(data->clk);
 	if (!uartclk) {
 		ret = device_property_read_u32(&pdev->dev, "clock-frequency", &uartclk);
-		if (ret)
-			return dev_err_probe(&pdev->dev, ret, "could not get clk rate\n");
+		if (ret) {
+			dev_err_probe(&pdev->dev, ret, "could not get clk rate\n");
+			goto dis_clk;
+		}
 	}
 
 	/* the HW-clock divider for bcm2835aux is 8,
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH -next] drivers/tty/serial: Add missing clk_disable_unprepare()
  2022-06-17  2:58 ` Guo Mengqi
@ 2022-06-27 12:06   ` Greg KH
  -1 siblings, 0 replies; 14+ messages in thread
From: Greg KH @ 2022-06-27 12:06 UTC (permalink / raw)
  To: Guo Mengqi
  Cc: jirislaby, f.fainelli, rjui, sbranden, bcm-kernel-feedback-list,
	nsaenz, athierry, linux-serial, linux-rpi-kernel,
	linux-arm-kernel, linux-kernel, xuqiang36

On Fri, Jun 17, 2022 at 10:58:27AM +0800, Guo Mengqi wrote:
> Add missing clk_disable_unprepare() when get clk rate fails.
> 
> Reported-by: Hulk Robot <hulkci@huawei.com>

How did the robot report it?

How was this tested?

You have read the documentation for how to correctly report problems
found and fixed by automated tools, right?  Please update the changelog
to include all of that information.

thanks,

greg k-h

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

* Re: [PATCH -next] drivers/tty/serial: Add missing clk_disable_unprepare()
@ 2022-06-27 12:06   ` Greg KH
  0 siblings, 0 replies; 14+ messages in thread
From: Greg KH @ 2022-06-27 12:06 UTC (permalink / raw)
  To: Guo Mengqi
  Cc: jirislaby, f.fainelli, rjui, sbranden, bcm-kernel-feedback-list,
	nsaenz, athierry, linux-serial, linux-rpi-kernel,
	linux-arm-kernel, linux-kernel, xuqiang36

On Fri, Jun 17, 2022 at 10:58:27AM +0800, Guo Mengqi wrote:
> Add missing clk_disable_unprepare() when get clk rate fails.
> 
> Reported-by: Hulk Robot <hulkci@huawei.com>

How did the robot report it?

How was this tested?

You have read the documentation for how to correctly report problems
found and fixed by automated tools, right?  Please update the changelog
to include all of that information.

thanks,

greg k-h

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH -next v2] serial: 8250_bcm2835aux: Add missing clk_disable_unprepare()
  2022-06-17  2:58 ` Guo Mengqi
@ 2022-07-06  3:00   ` Guo Mengqi
  -1 siblings, 0 replies; 14+ messages in thread
From: Guo Mengqi @ 2022-07-06  3:00 UTC (permalink / raw)
  To: gregkh
  Cc: jirislaby, f.fainelli, ilpo.jarvinen, athierry, linux-serial,
	linux-rpi-kernel, linux-arm-kernel, xuqiang36, weiyongjun1

The error path when get clock frequency fails in bcm2835aux_serial
driver does not correctly disable the clock.

This flaw was found using a static analysis tool "Hulk Robot", which
reported the following warning when analyzing linux-next/master:

    drivers/tty/serial/8250/8250_bcm2835aux.c:
    warning: clk_disable_unprepare_missing.cocci

The cocci script checks for the existence of clk_disable_unprepare()
paired with clk_prepare_enable().

Add the missing clk_disable_unprepare() to the error path.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Guo Mengqi <guomengqi3@huawei.com>
---
v2:
- Change title to more standard format
- Add details about how Hulk Robot report this issue.
---
 drivers/tty/serial/8250/8250_bcm2835aux.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_bcm2835aux.c b/drivers/tty/serial/8250/8250_bcm2835aux.c
index d9f1e618cfbd..f5718ff0cd8a 100644
--- a/drivers/tty/serial/8250/8250_bcm2835aux.c
+++ b/drivers/tty/serial/8250/8250_bcm2835aux.c
@@ -167,8 +167,10 @@ static int bcm2835aux_serial_probe(struct platform_device *pdev)
 	uartclk = clk_get_rate(data->clk);
 	if (!uartclk) {
 		ret = device_property_read_u32(&pdev->dev, "clock-frequency", &uartclk);
-		if (ret)
-			return dev_err_probe(&pdev->dev, ret, "could not get clk rate\n");
+		if (ret) {
+			dev_err_probe(&pdev->dev, ret, "could not get clk rate\n");
+			goto dis_clk;
+		}
 	}
 
 	/* the HW-clock divider for bcm2835aux is 8,
-- 
2.17.1


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

* [PATCH -next v2] serial: 8250_bcm2835aux: Add missing clk_disable_unprepare()
@ 2022-07-06  3:00   ` Guo Mengqi
  0 siblings, 0 replies; 14+ messages in thread
From: Guo Mengqi @ 2022-07-06  3:00 UTC (permalink / raw)
  To: gregkh
  Cc: jirislaby, f.fainelli, ilpo.jarvinen, athierry, linux-serial,
	linux-rpi-kernel, linux-arm-kernel, xuqiang36, weiyongjun1

The error path when get clock frequency fails in bcm2835aux_serial
driver does not correctly disable the clock.

This flaw was found using a static analysis tool "Hulk Robot", which
reported the following warning when analyzing linux-next/master:

    drivers/tty/serial/8250/8250_bcm2835aux.c:
    warning: clk_disable_unprepare_missing.cocci

The cocci script checks for the existence of clk_disable_unprepare()
paired with clk_prepare_enable().

Add the missing clk_disable_unprepare() to the error path.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Guo Mengqi <guomengqi3@huawei.com>
---
v2:
- Change title to more standard format
- Add details about how Hulk Robot report this issue.
---
 drivers/tty/serial/8250/8250_bcm2835aux.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_bcm2835aux.c b/drivers/tty/serial/8250/8250_bcm2835aux.c
index d9f1e618cfbd..f5718ff0cd8a 100644
--- a/drivers/tty/serial/8250/8250_bcm2835aux.c
+++ b/drivers/tty/serial/8250/8250_bcm2835aux.c
@@ -167,8 +167,10 @@ static int bcm2835aux_serial_probe(struct platform_device *pdev)
 	uartclk = clk_get_rate(data->clk);
 	if (!uartclk) {
 		ret = device_property_read_u32(&pdev->dev, "clock-frequency", &uartclk);
-		if (ret)
-			return dev_err_probe(&pdev->dev, ret, "could not get clk rate\n");
+		if (ret) {
+			dev_err_probe(&pdev->dev, ret, "could not get clk rate\n");
+			goto dis_clk;
+		}
 	}
 
 	/* the HW-clock divider for bcm2835aux is 8,
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH -next] drivers/tty/serial: Add missing clk_disable_unprepare()
  2022-06-17  2:58 ` Guo Mengqi
@ 2022-07-12  3:35   ` Florian Fainelli
  -1 siblings, 0 replies; 14+ messages in thread
From: Florian Fainelli @ 2022-07-12  3:35 UTC (permalink / raw)
  To: Guo Mengqi, gregkh, jirislaby, f.fainelli, rjui, sbranden,
	bcm-kernel-feedback-list, nsaenz, athierry, linux-serial,
	linux-rpi-kernel, linux-arm-kernel, linux-kernel
  Cc: xuqiang36



On 6/16/2022 7:58 PM, 'Guo Mengqi' via BCM-KERNEL-FEEDBACK-LIST,PDL wrote:
> Add missing clk_disable_unprepare() when get clk rate fails.
> 
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Guo Mengqi <guomengqi3@huawei.com>

Looks about right, can we use the same prefix as the majority of other 
changes:

serial: 8250_bcm2835aux: Add missing clk_disable_unprepare()

and slap a:

Fixes: fcc446c8aa63 ("serial: 8250_bcm2835aux: Add ACPI support")

Thanks!

> ---
>   drivers/tty/serial/8250/8250_bcm2835aux.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/tty/serial/8250/8250_bcm2835aux.c b/drivers/tty/serial/8250/8250_bcm2835aux.c
> index 2a1226a78a0c..21939bb44613 100644
> --- a/drivers/tty/serial/8250/8250_bcm2835aux.c
> +++ b/drivers/tty/serial/8250/8250_bcm2835aux.c
> @@ -166,8 +166,10 @@ static int bcm2835aux_serial_probe(struct platform_device *pdev)
>   	uartclk = clk_get_rate(data->clk);
>   	if (!uartclk) {
>   		ret = device_property_read_u32(&pdev->dev, "clock-frequency", &uartclk);
> -		if (ret)
> -			return dev_err_probe(&pdev->dev, ret, "could not get clk rate\n");
> +		if (ret) {
> +			dev_err_probe(&pdev->dev, ret, "could not get clk rate\n");
> +			goto dis_clk;
> +		}
>   	}
>   
>   	/* the HW-clock divider for bcm2835aux is 8,

-- 
Florian

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

* Re: [PATCH -next] drivers/tty/serial: Add missing clk_disable_unprepare()
@ 2022-07-12  3:35   ` Florian Fainelli
  0 siblings, 0 replies; 14+ messages in thread
From: Florian Fainelli @ 2022-07-12  3:35 UTC (permalink / raw)
  To: Guo Mengqi, gregkh, jirislaby, f.fainelli, rjui, sbranden,
	bcm-kernel-feedback-list, nsaenz, athierry, linux-serial,
	linux-rpi-kernel, linux-arm-kernel, linux-kernel
  Cc: xuqiang36



On 6/16/2022 7:58 PM, 'Guo Mengqi' via BCM-KERNEL-FEEDBACK-LIST,PDL wrote:
> Add missing clk_disable_unprepare() when get clk rate fails.
> 
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Guo Mengqi <guomengqi3@huawei.com>

Looks about right, can we use the same prefix as the majority of other 
changes:

serial: 8250_bcm2835aux: Add missing clk_disable_unprepare()

and slap a:

Fixes: fcc446c8aa63 ("serial: 8250_bcm2835aux: Add ACPI support")

Thanks!

> ---
>   drivers/tty/serial/8250/8250_bcm2835aux.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/tty/serial/8250/8250_bcm2835aux.c b/drivers/tty/serial/8250/8250_bcm2835aux.c
> index 2a1226a78a0c..21939bb44613 100644
> --- a/drivers/tty/serial/8250/8250_bcm2835aux.c
> +++ b/drivers/tty/serial/8250/8250_bcm2835aux.c
> @@ -166,8 +166,10 @@ static int bcm2835aux_serial_probe(struct platform_device *pdev)
>   	uartclk = clk_get_rate(data->clk);
>   	if (!uartclk) {
>   		ret = device_property_read_u32(&pdev->dev, "clock-frequency", &uartclk);
> -		if (ret)
> -			return dev_err_probe(&pdev->dev, ret, "could not get clk rate\n");
> +		if (ret) {
> +			dev_err_probe(&pdev->dev, ret, "could not get clk rate\n");
> +			goto dis_clk;
> +		}
>   	}
>   
>   	/* the HW-clock divider for bcm2835aux is 8,

-- 
Florian

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH -next] drivers/tty/serial: Add missing clk_disable_unprepare()
  2022-07-12  3:35   ` Florian Fainelli
@ 2022-07-13  7:37     ` guomengqi (A)
  -1 siblings, 0 replies; 14+ messages in thread
From: guomengqi (A) @ 2022-07-13  7:37 UTC (permalink / raw)
  To: Florian Fainelli, gregkh, jirislaby, rjui, sbranden,
	bcm-kernel-feedback-list, nsaenz, athierry, linux-serial,
	linux-rpi-kernel, linux-arm-kernel, linux-kernel
  Cc: xuqiang36

Hi Florian,

Yes I found it's better to use title of same style. I did not pay 
attention to this.

I will send a new version of this patch.

Thank you!

在 2022/7/12 11:35, Florian Fainelli 写道:
>
>
> On 6/16/2022 7:58 PM, 'Guo Mengqi' via BCM-KERNEL-FEEDBACK-LIST,PDL 
> wrote:
>> Add missing clk_disable_unprepare() when get clk rate fails.
>>
>> Reported-by: Hulk Robot <hulkci@huawei.com>
>> Signed-off-by: Guo Mengqi <guomengqi3@huawei.com>
>
> Looks about right, can we use the same prefix as the majority of other 
> changes:
>
> serial: 8250_bcm2835aux: Add missing clk_disable_unprepare()
>
> and slap a:
>
> Fixes: fcc446c8aa63 ("serial: 8250_bcm2835aux: Add ACPI support")
>
> Thanks!
>
>> ---
>>   drivers/tty/serial/8250/8250_bcm2835aux.c | 6 ++++--
>>   1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/tty/serial/8250/8250_bcm2835aux.c 
>> b/drivers/tty/serial/8250/8250_bcm2835aux.c
>> index 2a1226a78a0c..21939bb44613 100644
>> --- a/drivers/tty/serial/8250/8250_bcm2835aux.c
>> +++ b/drivers/tty/serial/8250/8250_bcm2835aux.c
>> @@ -166,8 +166,10 @@ static int bcm2835aux_serial_probe(struct 
>> platform_device *pdev)
>>       uartclk = clk_get_rate(data->clk);
>>       if (!uartclk) {
>>           ret = device_property_read_u32(&pdev->dev, 
>> "clock-frequency", &uartclk);
>> -        if (ret)
>> -            return dev_err_probe(&pdev->dev, ret, "could not get clk 
>> rate\n");
>> +        if (ret) {
>> +            dev_err_probe(&pdev->dev, ret, "could not get clk rate\n");
>> +            goto dis_clk;
>> +        }
>>       }
>>         /* the HW-clock divider for bcm2835aux is 8,
>

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

* Re: [PATCH -next] drivers/tty/serial: Add missing clk_disable_unprepare()
@ 2022-07-13  7:37     ` guomengqi (A)
  0 siblings, 0 replies; 14+ messages in thread
From: guomengqi (A) @ 2022-07-13  7:37 UTC (permalink / raw)
  To: Florian Fainelli, gregkh, jirislaby, rjui, sbranden,
	bcm-kernel-feedback-list, nsaenz, athierry, linux-serial,
	linux-rpi-kernel, linux-arm-kernel, linux-kernel
  Cc: xuqiang36

Hi Florian,

Yes I found it's better to use title of same style. I did not pay 
attention to this.

I will send a new version of this patch.

Thank you!

在 2022/7/12 11:35, Florian Fainelli 写道:
>
>
> On 6/16/2022 7:58 PM, 'Guo Mengqi' via BCM-KERNEL-FEEDBACK-LIST,PDL 
> wrote:
>> Add missing clk_disable_unprepare() when get clk rate fails.
>>
>> Reported-by: Hulk Robot <hulkci@huawei.com>
>> Signed-off-by: Guo Mengqi <guomengqi3@huawei.com>
>
> Looks about right, can we use the same prefix as the majority of other 
> changes:
>
> serial: 8250_bcm2835aux: Add missing clk_disable_unprepare()
>
> and slap a:
>
> Fixes: fcc446c8aa63 ("serial: 8250_bcm2835aux: Add ACPI support")
>
> Thanks!
>
>> ---
>>   drivers/tty/serial/8250/8250_bcm2835aux.c | 6 ++++--
>>   1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/tty/serial/8250/8250_bcm2835aux.c 
>> b/drivers/tty/serial/8250/8250_bcm2835aux.c
>> index 2a1226a78a0c..21939bb44613 100644
>> --- a/drivers/tty/serial/8250/8250_bcm2835aux.c
>> +++ b/drivers/tty/serial/8250/8250_bcm2835aux.c
>> @@ -166,8 +166,10 @@ static int bcm2835aux_serial_probe(struct 
>> platform_device *pdev)
>>       uartclk = clk_get_rate(data->clk);
>>       if (!uartclk) {
>>           ret = device_property_read_u32(&pdev->dev, 
>> "clock-frequency", &uartclk);
>> -        if (ret)
>> -            return dev_err_probe(&pdev->dev, ret, "could not get clk 
>> rate\n");
>> +        if (ret) {
>> +            dev_err_probe(&pdev->dev, ret, "could not get clk rate\n");
>> +            goto dis_clk;
>> +        }
>>       }
>>         /* the HW-clock divider for bcm2835aux is 8,
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH -next v3] serial: 8250_bcm2835aux: Add missing clk_disable_unprepare()
  2022-07-13  7:37     ` guomengqi (A)
@ 2022-07-15  2:33       ` Guo Mengqi
  -1 siblings, 0 replies; 14+ messages in thread
From: Guo Mengqi @ 2022-07-15  2:33 UTC (permalink / raw)
  To: gregkh, f.fainelli
  Cc: jirislaby, ilpo.jarvinen, athierry, linux-serial,
	linux-rpi-kernel, linux-arm-kernel, xuqiang36

The error path when get clock frequency fails in bcm2835aux_serial
driver does not correctly disable the clock.

This flaw was found using a static analysis tool "Hulk Robot", which
reported the following warning when analyzing linux-next/master:

    drivers/tty/serial/8250/8250_bcm2835aux.c:
    warning: clk_disable_unprepare_missing.cocci

The cocci script checks for the existence of clk_disable_unprepare()
paired with clk_prepare_enable().

Add the missing clk_disable_unprepare() to the error path.

Fixes: fcc446c8aa63 ("serial: 8250_bcm2835aux: Add ACPI support")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Guo Mengqi <guomengqi3@huawei.com>
---
v2:
- Change title to more standard format
- Add details about how Hulk Robot report this issue.
v3:
- add which commit this patch fixes
---
 drivers/tty/serial/8250/8250_bcm2835aux.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_bcm2835aux.c b/drivers/tty/serial/8250/8250_bcm2835aux.c
index 047e14ccb165..15a2387a5b25 100644
--- a/drivers/tty/serial/8250/8250_bcm2835aux.c
+++ b/drivers/tty/serial/8250/8250_bcm2835aux.c
@@ -167,8 +167,10 @@ static int bcm2835aux_serial_probe(struct platform_device *pdev)
 	uartclk = clk_get_rate(data->clk);
 	if (!uartclk) {
 		ret = device_property_read_u32(&pdev->dev, "clock-frequency", &uartclk);
-		if (ret)
-			return dev_err_probe(&pdev->dev, ret, "could not get clk rate\n");
+		if (ret) {
+			dev_err_probe(&pdev->dev, ret, "could not get clk rate\n");
+			goto dis_clk;
+		}
 	}
 
 	/* the HW-clock divider for bcm2835aux is 8,
-- 
2.17.1


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

* [PATCH -next v3] serial: 8250_bcm2835aux: Add missing clk_disable_unprepare()
@ 2022-07-15  2:33       ` Guo Mengqi
  0 siblings, 0 replies; 14+ messages in thread
From: Guo Mengqi @ 2022-07-15  2:33 UTC (permalink / raw)
  To: gregkh, f.fainelli
  Cc: jirislaby, ilpo.jarvinen, athierry, linux-serial,
	linux-rpi-kernel, linux-arm-kernel, xuqiang36

The error path when get clock frequency fails in bcm2835aux_serial
driver does not correctly disable the clock.

This flaw was found using a static analysis tool "Hulk Robot", which
reported the following warning when analyzing linux-next/master:

    drivers/tty/serial/8250/8250_bcm2835aux.c:
    warning: clk_disable_unprepare_missing.cocci

The cocci script checks for the existence of clk_disable_unprepare()
paired with clk_prepare_enable().

Add the missing clk_disable_unprepare() to the error path.

Fixes: fcc446c8aa63 ("serial: 8250_bcm2835aux: Add ACPI support")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Guo Mengqi <guomengqi3@huawei.com>
---
v2:
- Change title to more standard format
- Add details about how Hulk Robot report this issue.
v3:
- add which commit this patch fixes
---
 drivers/tty/serial/8250/8250_bcm2835aux.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_bcm2835aux.c b/drivers/tty/serial/8250/8250_bcm2835aux.c
index 047e14ccb165..15a2387a5b25 100644
--- a/drivers/tty/serial/8250/8250_bcm2835aux.c
+++ b/drivers/tty/serial/8250/8250_bcm2835aux.c
@@ -167,8 +167,10 @@ static int bcm2835aux_serial_probe(struct platform_device *pdev)
 	uartclk = clk_get_rate(data->clk);
 	if (!uartclk) {
 		ret = device_property_read_u32(&pdev->dev, "clock-frequency", &uartclk);
-		if (ret)
-			return dev_err_probe(&pdev->dev, ret, "could not get clk rate\n");
+		if (ret) {
+			dev_err_probe(&pdev->dev, ret, "could not get clk rate\n");
+			goto dis_clk;
+		}
 	}
 
 	/* the HW-clock divider for bcm2835aux is 8,
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH -next v3] serial: 8250_bcm2835aux: Add missing clk_disable_unprepare()
  2022-07-15  2:33       ` Guo Mengqi
@ 2022-07-15  2:41         ` Florian Fainelli
  -1 siblings, 0 replies; 14+ messages in thread
From: Florian Fainelli @ 2022-07-15  2:41 UTC (permalink / raw)
  To: Guo Mengqi, gregkh
  Cc: jirislaby, ilpo.jarvinen, athierry, linux-serial,
	linux-rpi-kernel, linux-arm-kernel, xuqiang36



On 7/14/2022 7:33 PM, Guo Mengqi wrote:
> The error path when get clock frequency fails in bcm2835aux_serial
> driver does not correctly disable the clock.
> 
> This flaw was found using a static analysis tool "Hulk Robot", which
> reported the following warning when analyzing linux-next/master:
> 
>      drivers/tty/serial/8250/8250_bcm2835aux.c:
>      warning: clk_disable_unprepare_missing.cocci
> 
> The cocci script checks for the existence of clk_disable_unprepare()
> paired with clk_prepare_enable().
> 
> Add the missing clk_disable_unprepare() to the error path.
> 
> Fixes: fcc446c8aa63 ("serial: 8250_bcm2835aux: Add ACPI support")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Guo Mengqi <guomengqi3@huawei.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

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

* Re: [PATCH -next v3] serial: 8250_bcm2835aux: Add missing clk_disable_unprepare()
@ 2022-07-15  2:41         ` Florian Fainelli
  0 siblings, 0 replies; 14+ messages in thread
From: Florian Fainelli @ 2022-07-15  2:41 UTC (permalink / raw)
  To: Guo Mengqi, gregkh
  Cc: jirislaby, ilpo.jarvinen, athierry, linux-serial,
	linux-rpi-kernel, linux-arm-kernel, xuqiang36



On 7/14/2022 7:33 PM, Guo Mengqi wrote:
> The error path when get clock frequency fails in bcm2835aux_serial
> driver does not correctly disable the clock.
> 
> This flaw was found using a static analysis tool "Hulk Robot", which
> reported the following warning when analyzing linux-next/master:
> 
>      drivers/tty/serial/8250/8250_bcm2835aux.c:
>      warning: clk_disable_unprepare_missing.cocci
> 
> The cocci script checks for the existence of clk_disable_unprepare()
> paired with clk_prepare_enable().
> 
> Add the missing clk_disable_unprepare() to the error path.
> 
> Fixes: fcc446c8aa63 ("serial: 8250_bcm2835aux: Add ACPI support")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Guo Mengqi <guomengqi3@huawei.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2022-07-15  2:42 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-17  2:58 [PATCH -next] drivers/tty/serial: Add missing clk_disable_unprepare() Guo Mengqi
2022-06-17  2:58 ` Guo Mengqi
2022-06-27 12:06 ` Greg KH
2022-06-27 12:06   ` Greg KH
2022-07-06  3:00 ` [PATCH -next v2] serial: 8250_bcm2835aux: " Guo Mengqi
2022-07-06  3:00   ` Guo Mengqi
2022-07-12  3:35 ` [PATCH -next] drivers/tty/serial: " Florian Fainelli
2022-07-12  3:35   ` Florian Fainelli
2022-07-13  7:37   ` guomengqi (A)
2022-07-13  7:37     ` guomengqi (A)
2022-07-15  2:33     ` [PATCH -next v3] serial: 8250_bcm2835aux: " Guo Mengqi
2022-07-15  2:33       ` Guo Mengqi
2022-07-15  2:41       ` Florian Fainelli
2022-07-15  2:41         ` Florian Fainelli

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.