From b57520d4a9520c7b1ed4d42f7e57697c7b9cdfa3 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Fri, 12 Sep 2008 18:02:07 +0000 Subject: [PATCH] * Don't leak the decoded instructions in case the device object cannot be allocated. * Remove accidentally added debug device id. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27461 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/drivers/input/usb_hid/HIDDevice.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/add-ons/kernel/drivers/input/usb_hid/HIDDevice.cpp b/src/add-ons/kernel/drivers/input/usb_hid/HIDDevice.cpp index 4cee5514a7..0ca2c4b74b 100644 --- a/src/add-ons/kernel/drivers/input/usb_hid/HIDDevice.cpp +++ b/src/add-ons/kernel/drivers/input/usb_hid/HIDDevice.cpp @@ -181,20 +181,21 @@ HIDDevice::MakeHIDDevice(usb_device device, } // determine device type and create the device object + HIDDevice *hidDevice = NULL; if (deviceType == USB_HID_DEVICE_TYPE_KEYBOARD) { - return new(std::nothrow) KeyboardDevice(device, interruptPipe, + hidDevice = new(std::nothrow) KeyboardDevice(device, interruptPipe, interfaceIndex, finalInstructions, instructionCount, totalReportSize); - } else if (deviceType == USB_HID_DEVICE_TYPE_MOUSE - || deviceType == 0x01250015) { - return new(std::nothrow) MouseDevice(device, interruptPipe, + } else if (deviceType == USB_HID_DEVICE_TYPE_MOUSE) { + hidDevice = new(std::nothrow) MouseDevice(device, interruptPipe, interfaceIndex, finalInstructions, instructionCount, totalReportSize); - } + } else + TRACE_ALWAYS("unsupported device type 0x%08lx\n", deviceType); - TRACE_ALWAYS("unsupported device type 0x%08lx\n", deviceType); - free(finalInstructions); - return NULL; + if (hidDevice == NULL) + free(finalInstructions); + return hidDevice; }