linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] counter: rz-mtu3-cnt: Unlock on error in rz_mtu3_count_ceiling_write()
@ 2023-04-20 15:02 Dan Carpenter
  2023-04-20 16:03 ` William Breathitt Gray
  2023-04-21  7:22 ` Lee Jones
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2023-04-20 15:02 UTC (permalink / raw)
  To: Biju Das
  Cc: William Breathitt Gray, Lee Jones, linux-iio, linux-renesas-soc,
	kernel-janitors

These error paths need to call mutex_unlock(&priv->lock) before
returning.  The lock is taken in rz_mtu3_lock_if_counter_is_valid().

Fixes: 25d21447d896 ("counter: Add Renesas RZ/G2L MTU3a counter driver")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
v2: I had the wrong function in the subject.  Also style changes.

 drivers/counter/rz-mtu3-cnt.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/counter/rz-mtu3-cnt.c b/drivers/counter/rz-mtu3-cnt.c
index a371bab68499..48c83933aa2f 100644
--- a/drivers/counter/rz-mtu3-cnt.c
+++ b/drivers/counter/rz-mtu3-cnt.c
@@ -358,13 +358,17 @@ static int rz_mtu3_count_ceiling_write(struct counter_device *counter,
 	switch (count->id) {
 	case RZ_MTU3_16_BIT_MTU1_CH:
 	case RZ_MTU3_16_BIT_MTU2_CH:
-		if (ceiling > U16_MAX)
+		if (ceiling > U16_MAX) {
+			mutex_unlock(&priv->lock);
 			return -ERANGE;
+		}
 		priv->mtu_16bit_max[ch_id] = ceiling;
 		break;
 	case RZ_MTU3_32_BIT_CH:
-		if (ceiling > U32_MAX)
+		if (ceiling > U32_MAX) {
+			mutex_unlock(&priv->lock);
 			return -ERANGE;
+		}
 		priv->mtu_32bit_max = ceiling;
 		break;
 	default:
-- 
2.39.2


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

* Re: [PATCH v2] counter: rz-mtu3-cnt: Unlock on error in rz_mtu3_count_ceiling_write()
  2023-04-20 15:02 [PATCH v2] counter: rz-mtu3-cnt: Unlock on error in rz_mtu3_count_ceiling_write() Dan Carpenter
@ 2023-04-20 16:03 ` William Breathitt Gray
  2023-04-21  7:22 ` Lee Jones
  1 sibling, 0 replies; 3+ messages in thread
From: William Breathitt Gray @ 2023-04-20 16:03 UTC (permalink / raw)
  To: Lee Jones, Dan Carpenter
  Cc: Biju Das, linux-iio, linux-renesas-soc, kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1579 bytes --]

On Thu, Apr 20, 2023 at 06:02:11PM +0300, Dan Carpenter wrote:
> These error paths need to call mutex_unlock(&priv->lock) before
> returning.  The lock is taken in rz_mtu3_lock_if_counter_is_valid().
> 
> Fixes: 25d21447d896 ("counter: Add Renesas RZ/G2L MTU3a counter driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Acked-by: William Breathitt Gray <william.gray@linaro.org>

Despite this being a fix, I think this driver currently is only in the
mfd tree, right? So I assume Lee Jones will pick this up for there.

Thanks,

William Breathitt Gray

> ---
> v2: I had the wrong function in the subject.  Also style changes.
> 
>  drivers/counter/rz-mtu3-cnt.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/counter/rz-mtu3-cnt.c b/drivers/counter/rz-mtu3-cnt.c
> index a371bab68499..48c83933aa2f 100644
> --- a/drivers/counter/rz-mtu3-cnt.c
> +++ b/drivers/counter/rz-mtu3-cnt.c
> @@ -358,13 +358,17 @@ static int rz_mtu3_count_ceiling_write(struct counter_device *counter,
>  	switch (count->id) {
>  	case RZ_MTU3_16_BIT_MTU1_CH:
>  	case RZ_MTU3_16_BIT_MTU2_CH:
> -		if (ceiling > U16_MAX)
> +		if (ceiling > U16_MAX) {
> +			mutex_unlock(&priv->lock);
>  			return -ERANGE;
> +		}
>  		priv->mtu_16bit_max[ch_id] = ceiling;
>  		break;
>  	case RZ_MTU3_32_BIT_CH:
> -		if (ceiling > U32_MAX)
> +		if (ceiling > U32_MAX) {
> +			mutex_unlock(&priv->lock);
>  			return -ERANGE;
> +		}
>  		priv->mtu_32bit_max = ceiling;
>  		break;
>  	default:
> -- 
> 2.39.2
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

* Re: [PATCH v2] counter: rz-mtu3-cnt: Unlock on error in rz_mtu3_count_ceiling_write()
  2023-04-20 15:02 [PATCH v2] counter: rz-mtu3-cnt: Unlock on error in rz_mtu3_count_ceiling_write() Dan Carpenter
  2023-04-20 16:03 ` William Breathitt Gray
@ 2023-04-21  7:22 ` Lee Jones
  1 sibling, 0 replies; 3+ messages in thread
From: Lee Jones @ 2023-04-21  7:22 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Biju Das, William Breathitt Gray, linux-iio, linux-renesas-soc,
	kernel-janitors

On Thu, 20 Apr 2023, Dan Carpenter wrote:

> These error paths need to call mutex_unlock(&priv->lock) before
> returning.  The lock is taken in rz_mtu3_lock_if_counter_is_valid().
> 
> Fixes: 25d21447d896 ("counter: Add Renesas RZ/G2L MTU3a counter driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> v2: I had the wrong function in the subject.  Also style changes.
> 
>  drivers/counter/rz-mtu3-cnt.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)

Applied, thanks

-- 
Lee Jones [李琼斯]

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

end of thread, other threads:[~2023-04-21  7:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-20 15:02 [PATCH v2] counter: rz-mtu3-cnt: Unlock on error in rz_mtu3_count_ceiling_write() Dan Carpenter
2023-04-20 16:03 ` William Breathitt Gray
2023-04-21  7:22 ` Lee Jones

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