All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Alessandro Zanni <alessandro.zanni87@gmail.com>
Cc: erick.archer@outlook.com, zhoubinbin@loongson.cn,
	jay_lee@pixart.com, jon_xie@pixart.com,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	skhan@linuxfoundation.org, anupnewsmail@gmail.com
Subject: Re: [PATCH] input: psmouse: Add unlock mutex before to exit psmouse_attr_set_protocol
Date: Tue, 1 Oct 2024 06:09:40 -0700	[thread overview]
Message-ID: <Zvv0lDZZVDM2CbHf@google.com> (raw)
In-Reply-To: <20241001110839.44762-1-alessandro.zanni87@gmail.com>

Hi Alessandro,

On Tue, Oct 01, 2024 at 01:08:38PM +0200, Alessandro Zanni wrote:
> In error handling code for "no such device" or memory already used,
> release the mutex before to return.
> 
> Found with Coccinelle static analisys tool,
> script: https://coccinelle.gitlabpages.inria.fr/website/rules/mut.cocci
> 
> Signed-off-by: Alessandro Zanni <alessandro.zanni87@gmail.com>
> ---
>  drivers/input/mouse/psmouse-base.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
> index 5a4defe9cf32..cb3a125d8d7c 100644
> --- a/drivers/input/mouse/psmouse-base.c
> +++ b/drivers/input/mouse/psmouse-base.c
> @@ -1930,11 +1930,13 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co
>  
>  		if (serio->drv != &psmouse_drv) {
>  			input_free_device(new_dev);
> +			mutex_unlock(&psmouse_mutex);

I am sorry, bit this makes absolutely no sense. This mutex is taken
(and then released) in psmouse_attr_set_helper() wrapper.
psmouse_attr_set_protocol() momentarily drops and then reacquires it,
but it should not release it either failure or success parts.

Thanks.

-- 
Dmitry

      reply	other threads:[~2024-10-01 13:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-01 11:08 [PATCH] input: psmouse: Add unlock mutex before to exit psmouse_attr_set_protocol Alessandro Zanni
2024-10-01 13:09 ` Dmitry Torokhov [this message]

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=Zvv0lDZZVDM2CbHf@google.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=alessandro.zanni87@gmail.com \
    --cc=anupnewsmail@gmail.com \
    --cc=erick.archer@outlook.com \
    --cc=jay_lee@pixart.com \
    --cc=jon_xie@pixart.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=zhoubinbin@loongson.cn \
    /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 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.