Skip to content

Commit 61890dc

Browse files
Kostrgregkh
authored andcommitted
usb: gadget: f_hid: fix report descriptor allocation
The commit 89ff3df ("usb: gadget: f_hid: fix f_hidg lifetime vs cdev") has introduced a bug that leads to hid device corruption after the replug operation. Reverse device managed memory allocation for the report descriptor to fix the issue. Tested: This change was tested on the AMD EthanolX CRB server with the BMC based on the OpenBMC distribution. The BMC provides KVM functionality via the USB gadget device: - before: KVM page refresh results in a broken USB device, - after: KVM page refresh works without any issues. Fixes: 89ff3df ("usb: gadget: f_hid: fix f_hidg lifetime vs cdev") Cc: [email protected] Signed-off-by: Konstantin Aladyshev <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 24be0b3 commit 61890dc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/usb/gadget/function/f_hid.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ static void hidg_release(struct device *dev)
9292
{
9393
struct f_hidg *hidg = container_of(dev, struct f_hidg, dev);
9494

95+
kfree(hidg->report_desc);
9596
kfree(hidg->set_report_buf);
9697
kfree(hidg);
9798
}
@@ -1287,9 +1288,9 @@ static struct usb_function *hidg_alloc(struct usb_function_instance *fi)
12871288
hidg->report_length = opts->report_length;
12881289
hidg->report_desc_length = opts->report_desc_length;
12891290
if (opts->report_desc) {
1290-
hidg->report_desc = devm_kmemdup(&hidg->dev, opts->report_desc,
1291-
opts->report_desc_length,
1292-
GFP_KERNEL);
1291+
hidg->report_desc = kmemdup(opts->report_desc,
1292+
opts->report_desc_length,
1293+
GFP_KERNEL);
12931294
if (!hidg->report_desc) {
12941295
ret = -ENOMEM;
12951296
goto err_put_device;

0 commit comments

Comments
 (0)