1 From a0dad3b2a4841f70f96145a2f60ffd04e5d584ad Mon Sep 17 00:00:00 2001
2 From: Prasad J Pandit <pjp@fedoraproject.org>
3 Date: Tue, 16 Feb 2016 15:34:14 +0530
4 Subject: [PATCH] usb: ohci avoid multiple eof timers
6 When transitioning an OHCI controller to the OHCI_USB_OPERATIONAL
7 state, it creates an eof timer object in 'ohci_bus_start'.
8 It does not check if one already exists. This results in memory
9 leakage and null dereference issue. Add a check to avoid it.
11 Reported-by: Zuozhi Fzz <zuozhi.fzz@alibaba-inc.com>
12 Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
17 hw/usb/hcd-ohci.c | 10 ++++++++++
18 1 file changed, 10 insertions(+)
20 diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
21 index ffab561..ccd5ac4 100644
22 --- a/hw/usb/hcd-ohci.c
23 +++ b/hw/usb/hcd-ohci.c
24 @@ -1348,6 +1348,16 @@ static void ohci_frame_boundary(void *opaque)
26 static int ohci_bus_start(OHCIState *ohci)
28 + if (!ohci->eof_timer) {
29 + ohci->eof_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
30 + ohci_frame_boundary, ohci);
32 + if (!ohci->eof_timer) {
33 + trace_usb_ohci_bus_eof_timer_failed(ohci->name);
38 trace_usb_ohci_start(ohci->name);
40 /* Delay the first SOF event by one frame time as