diff options
-rw-r--r-- | drivers/hid/usbhid/hid-core.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index 482f936fc29b..6b9bad540702 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c | |||
@@ -331,9 +331,12 @@ static int hid_submit_out(struct hid_device *hid) | |||
331 | usbhid->urbout->transfer_buffer_length = ((report->size - 1) >> 3) + | 331 | usbhid->urbout->transfer_buffer_length = ((report->size - 1) >> 3) + |
332 | 1 + (report->id > 0); | 332 | 1 + (report->id > 0); |
333 | usbhid->urbout->dev = hid_to_usb_dev(hid); | 333 | usbhid->urbout->dev = hid_to_usb_dev(hid); |
334 | memcpy(usbhid->outbuf, raw_report, | 334 | if (raw_report) { |
335 | usbhid->urbout->transfer_buffer_length); | 335 | memcpy(usbhid->outbuf, raw_report, |
336 | kfree(raw_report); | 336 | usbhid->urbout->transfer_buffer_length); |
337 | kfree(raw_report); | ||
338 | usbhid->out[usbhid->outtail].raw_report = NULL; | ||
339 | } | ||
337 | 340 | ||
338 | dbg_hid("submitting out urb\n"); | 341 | dbg_hid("submitting out urb\n"); |
339 | 342 | ||
@@ -362,8 +365,11 @@ static int hid_submit_ctrl(struct hid_device *hid) | |||
362 | if (dir == USB_DIR_OUT) { | 365 | if (dir == USB_DIR_OUT) { |
363 | usbhid->urbctrl->pipe = usb_sndctrlpipe(hid_to_usb_dev(hid), 0); | 366 | usbhid->urbctrl->pipe = usb_sndctrlpipe(hid_to_usb_dev(hid), 0); |
364 | usbhid->urbctrl->transfer_buffer_length = len; | 367 | usbhid->urbctrl->transfer_buffer_length = len; |
365 | memcpy(usbhid->ctrlbuf, raw_report, len); | 368 | if (raw_report) { |
366 | kfree(raw_report); | 369 | memcpy(usbhid->ctrlbuf, raw_report, len); |
370 | kfree(raw_report); | ||
371 | usbhid->ctrl[usbhid->ctrltail].raw_report = NULL; | ||
372 | } | ||
367 | } else { | 373 | } else { |
368 | int maxpacket, padlen; | 374 | int maxpacket, padlen; |
369 | 375 | ||