From: John Keeping <john@metanate.com>
To: linux-usb@vger.kernel.org
Cc: 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>,
John Keeping <john@metanate.com>, Lee Jones <lee@kernel.org>,
Alan Stern <stern@rowland.harvard.edu>
Subject: [PATCH 2/3] usb: gadget: f_hid: fix refcount leak on error path
Date: Tue, 22 Nov 2022 12:35:22 +0000 [thread overview]
Message-ID: <20221122123523.3068034-3-john@metanate.com> (raw)
In-Reply-To: <20221122123523.3068034-1-john@metanate.com>
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>
---
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);
}
--
2.38.1
next prev parent reply other threads:[~2022-11-22 12:35 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 ` John Keeping [this message]
2022-11-23 11:55 ` [PATCH 2/3] usb: gadget: f_hid: fix refcount leak on error path Andrzej Pietrasiewicz
2022-11-23 12:04 ` John Keeping
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=20221122123523.3068034-3-john@metanate.com \
--to=john@metanate.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;
as well as URLs for NNTP newsgroup(s).