From: John Keeping <john@metanate.com>
To: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
Cc: linux-usb@vger.kernel.org,
Fabien Chouteau <fabien.chouteau@barco.com>,
Peter Korsgaard <peter.korsgaard@barco.com>,
Felipe Balbi <balbi@ti.com>,
Andrzej Pietrasiewicz <andrzej.p@samsung.com>,
linux-kernel@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Lee Jones <lee@kernel.org>,
Alan Stern <stern@rowland.harvard.edu>
Subject: Re: [PATCH 2/3] usb: gadget: f_hid: fix refcount leak on error path
Date: Wed, 23 Nov 2022 12:04:33 +0000 [thread overview]
Message-ID: <Y34MUUyOSgwLWQA+@donbot> (raw)
In-Reply-To: <dcd180f6-7769-3bc5-403f-8960e922bb50@collabora.com>
On Wed, Nov 23, 2022 at 12:55:14PM +0100, Andrzej Pietrasiewicz wrote:
> W dniu 22.11.2022 o 13:35, John Keeping pisze:
> > When failing to allocate report_desc, opts->refcnt has already been
> > incremented so it needs to be decremented to avoid leaving the options
> > structure permanently locked.
> >
> > Fixes: 21a9476a7ba8 ("usb: gadget: hid: add configfs support")
> > Signed-off-by: John Keeping <john@metanate.com>
>
> I'd personally place the bugfix before patches 1 and 3, but anyway
Patch 1 is also a bugfix, I ordered 1 & 2 based on the order of the
commits in the Fixes: tags.
> Reviewed-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
>
> > ---
> > drivers/usb/gadget/function/f_hid.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c
> > index 8b8bbeaa27cb..6be6009f911e 100644
> > --- a/drivers/usb/gadget/function/f_hid.c
> > +++ b/drivers/usb/gadget/function/f_hid.c
> > @@ -1292,6 +1292,7 @@ static struct usb_function *hidg_alloc(struct usb_function_instance *fi)
> > GFP_KERNEL);
> > if (!hidg->report_desc) {
> > put_device(&hidg->dev);
> > + --opts->refcnt;
> > mutex_unlock(&opts->lock);
> > return ERR_PTR(-ENOMEM);
> > }
>
next prev parent reply other threads:[~2022-11-23 12:04 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-22 12:35 [PATCH 0/3] usb: gadget: f_hid: fix f_hidg lifetime vs cdev John Keeping
2022-11-22 12:35 ` [PATCH 1/3] " John Keeping
2022-11-23 11:52 ` Andrzej Pietrasiewicz
2022-11-23 12:03 ` John Keeping
2022-11-23 12:20 ` Andrzej Pietrasiewicz
2022-11-22 12:35 ` [PATCH 2/3] usb: gadget: f_hid: fix refcount leak on error path John Keeping
2022-11-23 11:55 ` Andrzej Pietrasiewicz
2022-11-23 12:04 ` John Keeping [this message]
2022-11-22 12:35 ` [PATCH 3/3] usb: gadget: f_hid: tidy error handling in hidg_alloc John Keeping
2022-11-23 12:19 ` Andrzej Pietrasiewicz
2022-11-22 18:18 ` [PATCH 0/3] usb: gadget: f_hid: fix f_hidg lifetime vs cdev Lee Jones
2022-11-28 14:04 ` Lee Jones
2022-11-28 17:47 ` Greg Kroah-Hartman
2022-11-29 8:59 ` Lee Jones
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=Y34MUUyOSgwLWQA+@donbot \
--to=john@metanate.com \
--cc=andrzej.p@collabora.com \
--cc=andrzej.p@samsung.com \
--cc=balbi@ti.com \
--cc=fabien.chouteau@barco.com \
--cc=gregkh@linuxfoundation.org \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=peter.korsgaard@barco.com \
--cc=stern@rowland.harvard.edu \
/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