From: William Breathitt Gray <william.gray@linaro.org>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Biju Das <biju.das.jz@bp.renesas.com>, Lee Jones <lee@kernel.org>,
linux-iio@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] counter: rz-mtu3-cnt: Unlock on error in rz_mtu3_count_write()
Date: Wed, 19 Apr 2023 10:36:49 -0400 [thread overview]
Message-ID: <ZD/8gbcin4RQYd+A@fedora> (raw)
In-Reply-To: <93ec19d1-3b74-4644-9f67-b88c08e79752@kili.mountain>
[-- Attachment #1: Type: text/plain, Size: 1956 bytes --]
On Wed, Apr 19, 2023 at 05:23:55PM +0300, Dan Carpenter wrote:
> The return -ERANGE error paths need to call mutex_unlock(&priv->lock);
> before returning.
>
> Fixes: 25d21447d896 ("counter: Add Renesas RZ/G2L MTU3a counter driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> drivers/counter/rz-mtu3-cnt.c | 20 ++++++++++++--------
> 1 file changed, 12 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/counter/rz-mtu3-cnt.c b/drivers/counter/rz-mtu3-cnt.c
> index a371bab68499..aeadce5e2853 100644
> --- a/drivers/counter/rz-mtu3-cnt.c
> +++ b/drivers/counter/rz-mtu3-cnt.c
> @@ -358,19 +358,23 @@ 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)
> - return -ERANGE;
> + if (ceiling > U16_MAX) {
> + ret = -ERANGE;
> + goto unlock;
> + }
> priv->mtu_16bit_max[ch_id] = ceiling;
> break;
> case RZ_MTU3_32_BIT_CH:
> - if (ceiling > U32_MAX)
> - return -ERANGE;
> + if (ceiling > U32_MAX) {
> + ret = -ERANGE;
> + goto unlock;
> + }
> priv->mtu_32bit_max = ceiling;
> break;
> default:
> /* should never reach this path */
> - mutex_unlock(&priv->lock);
> - return -EINVAL;
> + ret = -EINVAL;
> + goto unlock;
> }
>
> pm_runtime_get_sync(ch->dev);
> @@ -381,9 +385,9 @@ static int rz_mtu3_count_ceiling_write(struct counter_device *counter,
>
> rz_mtu3_8bit_ch_write(ch, RZ_MTU3_TCR, RZ_MTU3_TCR_CCLR_TGRA);
> pm_runtime_put(ch->dev);
> +unlock:
> mutex_unlock(&priv->lock);
> -
> - return 0;
> + return ret;
> }
>
> static void rz_mtu3_32bit_cnt_setting(struct counter_device *counter)
> --
> 2.39.2
>
The lock is acquired by rz_mtu3_lock_if_counter_is_valid(), so that
function needs a sparse __acquires(&priv->lock) annotation too.
William Breathitt Gray
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2023-04-19 14:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-19 14:23 [PATCH] counter: rz-mtu3-cnt: Unlock on error in rz_mtu3_count_write() Dan Carpenter
2023-04-19 14:36 ` William Breathitt Gray [this message]
2023-04-19 15:37 ` Dan Carpenter
2023-04-19 15:30 ` William Breathitt Gray
2023-04-20 6:04 ` Biju Das
2023-04-20 14:17 ` William Breathitt Gray
2023-04-20 14:58 ` Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZD/8gbcin4RQYd+A@fedora \
--to=william.gray@linaro.org \
--cc=biju.das.jz@bp.renesas.com \
--cc=dan.carpenter@linaro.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=lee@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox