Skip to content

Commit 1e28dfd

Browse files
Dan Carpenterlag-linaro
authored andcommitted
counter: rz-mtu3-cnt: Unlock on error in rz_mtu3_count_ceiling_write()
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: 25d2144 ("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> Signed-off-by: Lee Jones <lee@kernel.org> Link: https://lore.kernel.org/r/7b535d6b-6031-493a-84f6-82842089e637@kili.mountain
1 parent 1706636 commit 1e28dfd

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

drivers/counter/rz-mtu3-cnt.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,17 @@ static int rz_mtu3_count_ceiling_write(struct counter_device *counter,
358358
switch (count->id) {
359359
case RZ_MTU3_16_BIT_MTU1_CH:
360360
case RZ_MTU3_16_BIT_MTU2_CH:
361-
if (ceiling > U16_MAX)
361+
if (ceiling > U16_MAX) {
362+
mutex_unlock(&priv->lock);
362363
return -ERANGE;
364+
}
363365
priv->mtu_16bit_max[ch_id] = ceiling;
364366
break;
365367
case RZ_MTU3_32_BIT_CH:
366-
if (ceiling > U32_MAX)
368+
if (ceiling > U32_MAX) {
369+
mutex_unlock(&priv->lock);
367370
return -ERANGE;
371+
}
368372
priv->mtu_32bit_max = ceiling;
369373
break;
370374
default:

0 commit comments

Comments
 (0)