From: Dan Carpenter <dan.carpenter@linaro.org>
To: claudiu beznea <claudiu.beznea@tuxon.dev>
Cc: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Linus Walleij <linus.walleij@linaro.org>,
linux-renesas-soc@vger.kernel.org, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] pinctrl: renesas: rzg2l: Fix double unlock in rzg2l_dt_subnode_to_map()
Date: Fri, 12 Jan 2024 12:53:10 +0300 [thread overview]
Message-ID: <300d204b-8151-45f3-9977-7ceb3a5c5eb0@moroto.mountain> (raw)
In-Reply-To: <185128ab-f229-4b40-91cd-ebdc138e11ac@tuxon.dev>
On Fri, Jan 12, 2024 at 10:55:40AM +0200, claudiu beznea wrote:
> Hi, Dan,
>
> Thanks for your patch!
>
> On 10.01.2024 20:41, Dan Carpenter wrote:
> > If rzg2l_map_add_config() fails then the error handling calls
> > mutex_unlock(&pctrl->mutex) but we're not holding that mutex. Move
> > the unlocks to before the gotos to avoid this situation.
> >
> > Fixes: d3aaa7203a17 ("pinctrl: renesas: rzg2l: Add pin configuration support for pinmux groups")
> > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> > ---
> > (Not tested).
>
> I've tested it on RZ/G3S SoC and all is good.
>
> However, I think, to keep the locking scheme unchanged and simpler (FMPOV),
> commit d3aaa7203a17 ("pinctrl: renesas: rzg2l: Add pin configuration
> support for pinmux groups") should have been call rzg2l_map_add_config()
> just before the mutex is locked. That would be the following diff:
>
> --- a/drivers/pinctrl/renesas/pinctrl-rzg2l.c
> +++ b/drivers/pinctrl/renesas/pinctrl-rzg2l.c
> @@ -447,6 +447,16 @@ static int rzg2l_dt_subnode_to_map(struct pinctrl_dev
> *pctldev,
> name = np->name;
> }
>
> + if (num_configs) {
> + ret = rzg2l_map_add_config(&maps[idx], name,
> + PIN_MAP_TYPE_CONFIGS_GROUP,
> + configs, num_configs);
> + if (ret < 0)
> + goto done;
> +
> + idx++;
> + }
> +
> mutex_lock(&pctrl->mutex);
>
> /* Register a single pin group listing all the pins we read from DT */
> @@ -474,16 +484,6 @@ static int rzg2l_dt_subnode_to_map(struct pinctrl_dev
> *pctldev,
> maps[idx].data.mux.function = name;
> idx++;
^^^^^
>
> - if (num_configs) {
> - ret = rzg2l_map_add_config(&maps[idx], name,
> - PIN_MAP_TYPE_CONFIGS_GROUP,
> - configs, num_configs);
> - if (ret < 0)
> - goto remove_group;
> -
> - idx++;
> - }
Does the ordering of the maps[] not matter?
> -
> dev_dbg(pctrl->dev, "Parsed %pOF with %d pins\n", np, num_pinmux);
> ret = 0;
> goto done;
>
> Would you mind doing it like this?
>
> Please, let me know if you want me to handle it.
Either way is fine. Whatever is easiest.
regards,
dan carpenter
next prev parent reply other threads:[~2024-01-12 9:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-10 18:41 Dan Carpenter
2024-01-12 8:55 ` claudiu beznea
2024-01-12 9:53 ` Dan Carpenter [this message]
2024-01-12 12:05 ` claudiu beznea
2024-01-12 12:28 ` 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=300d204b-8151-45f3-9977-7ceb3a5c5eb0@moroto.mountain \
--to=dan.carpenter@linaro.org \
--cc=claudiu.beznea.uj@bp.renesas.com \
--cc=claudiu.beznea@tuxon.dev \
--cc=geert+renesas@glider.be \
--cc=kernel-janitors@vger.kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@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
all inboxes | Powered by JetHome®