qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] usb: ohci avoid multiple eof timers
@ 2016-02-16 10:04 P J P
  2016-02-16 10:56 ` Laurent Vivier
  2016-02-16 14:17 ` Gerd Hoffmann
  0 siblings, 2 replies; 4+ messages in thread
From: P J P @ 2016-02-16 10:04 UTC (permalink / raw)
  To: Qemu Developers; +Cc: Zuozhi Fzz, Gerd Hoffmann, Prasad J Pandit

From: Prasad J Pandit <pjp@fedoraproject.org>

When transitioning an OHCI controller to the OHCI_USB_OPERATIONAL
state, it creates an eof timer object in 'ohci_bus_start'.
It does not check if one already exists. This results in memory
leakage and null dereference issue. Add a check to avoid it.

Reported-by: Zuozhi Fzz <zuozhi.fzz@alibaba-inc.com>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
---
 hw/usb/hcd-ohci.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index 7d65818..15f0b44 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -1331,11 +1331,11 @@ static void ohci_frame_boundary(void *opaque)
  */
 static int ohci_bus_start(OHCIState *ohci)
 {
-    ohci->eof_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
-                    ohci_frame_boundary,
-                    ohci);
-
-    if (ohci->eof_timer == NULL) {
+    if (!ohci->eof_timer) {
+        ohci->eof_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
+                                        ohci_frame_boundary, ohci);
+    }
+    if (!ohci->eof_timer) {
         trace_usb_ohci_bus_eof_timer_failed(ohci->name);
         ohci_die(ohci);
         return 0;
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-02-16 17:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-16 10:04 [Qemu-devel] [PATCH] usb: ohci avoid multiple eof timers P J P
2016-02-16 10:56 ` Laurent Vivier
2016-02-16 14:17 ` Gerd Hoffmann
2016-02-16 17:32   ` P J P

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).