diff mbox series

回复: [PATCH] HID: usbhid: fix memleak for ctrl or out raw_report

Message ID BYAPR11MB2632FAF1DA3F5EB27A53CF80FFFB0@BYAPR11MB2632.namprd11.prod.outlook.com (mailing list archive)
State New, archived
Headers show
Series 回复: [PATCH] HID: usbhid: fix memleak for ctrl or out raw_report | expand

Commit Message

Zhang, Qiang Nov. 24, 2020, 6:31 a.m. UTC

diff mbox series

Patch

diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 17a29ee0ac6c..f8a49f8d4015 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -1209,6 +1209,7 @@  static int usbhid_start(struct hid_device *hid)
 static void usbhid_stop(struct hid_device *hid)
 {
        struct usbhid_device *usbhid = hid->driver_data;
+       int index;

        if (WARN_ON(!usbhid))
                return;
@@ -1232,6 +1233,13 @@  static void usbhid_stop(struct hid_device *hid)

        hid->claimed = 0;

+       for (index = 0; index < HID_CONTROL_FIFO_SIZE; index++) {
+               if (usbhid->ctrl[index].raw_report)
+                       kfree(usbhid->ctrl[index].raw_report);
+               if (usbhid->out[index].raw_report)
+                       kfree(usbhid->out[index].raw_report);
+       }
+
        usb_free_urb(usbhid->urbin);
        usb_free_urb(usbhid->urbctrl);
        usb_free_urb(usbhid->urbout);