Author: hpoussin
Date: Fri Jul 14 02:20:54 2006
New Revision: 23052
URL:
http://svn.reactos.org/svn/reactos?rev=23052&view=rev
Log:
In case of error, free the input data buffer only if we just allocated it.
Modified:
trunk/reactos/drivers/input/kbdclass/kbdclass.c
trunk/reactos/drivers/input/mouclass/mouclass.c
Modified: trunk/reactos/drivers/input/kbdclass/kbdclass.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/input/kbdclass/kbd…
==============================================================================
--- trunk/reactos/drivers/input/kbdclass/kbdclass.c (original)
+++ trunk/reactos/drivers/input/kbdclass/kbdclass.c Fri Jul 14 02:20:54 2006
@@ -126,7 +126,7 @@
PLIST_ENTRY Head =
&((PCLASS_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->ListHead;
if (Head->Flink != Head)
{
- /* We have at least one keyboard */
+ /* We have at least one device */
PPORT_DEVICE_EXTENSION DevExt = CONTAINING_RECORD(Head->Flink,
PORT_DEVICE_EXTENSION, ListEntry);
IoGetCurrentIrpStackLocation(Irp)->MajorFunction =
IRP_MJ_INTERNAL_DEVICE_CONTROL;
IoSkipCurrentIrpStackLocation(Irp);
@@ -553,6 +553,9 @@
CONNECT_DATA ConnectData;
NTSTATUS Status;
+ DPRINT("Connecting PortDO %p [%wZ] to ClassDO %p\n",
+ PortDO, &PortDO->DriverObject->DriverName, ClassDO);
+
KeInitializeEvent(&Event, NotificationEvent, FALSE);
ConnectData.ClassDeviceObject = ClassDO;
@@ -588,6 +591,18 @@
}
return IoStatus.Status;
+}
+
+/* Send IOCTL_INTERNAL_*_DISCONNECT to port */
+static NTSTATUS
+DisconnectPortDriver(
+ IN PDEVICE_OBJECT PortDO)
+{
+ DPRINT("Disconnecting PortDO %p [%wZ]\n",
+ PortDO, &PortDO->DriverObject->DriverName);
+
+ DPRINT1("FIXME: Need to send IOCTL_INTERNAL_*_DISCONNECT\n");
+ return STATUS_NOT_IMPLEMENTED;
}
static NTSTATUS NTAPI
@@ -686,16 +701,17 @@
cleanup:
if (!(Fdo->Flags & DO_DEVICE_INITIALIZING))
- DPRINT1("FIXME: Need to send IOCTL_INTERNAL_*_DISCONNECT\n");
+ DisconnectPortDriver(Fdo);
if (DeviceExtension)
{
if (DeviceExtension->LowerDevice)
IoDetachDevice(DeviceExtension->LowerDevice);
- if (DriverExtension->ConnectMultiplePorts && DeviceExtension->ClassDO)
+ if (!DriverExtension->ConnectMultiplePorts && DeviceExtension->ClassDO)
{
PCLASS_DEVICE_EXTENSION ClassDeviceExtension;
ClassDeviceExtension =
(PCLASS_DEVICE_EXTENSION)DeviceExtension->ClassDO->DeviceExtension;
ExFreePool(ClassDeviceExtension->PortData);
+ IoDeleteDevice(DeviceExtension->ClassDO);
}
}
if (Fdo)
Modified: trunk/reactos/drivers/input/mouclass/mouclass.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/input/mouclass/mou…
==============================================================================
--- trunk/reactos/drivers/input/mouclass/mouclass.c (original)
+++ trunk/reactos/drivers/input/mouclass/mouclass.c Fri Jul 14 02:20:54 2006
@@ -123,7 +123,7 @@
PLIST_ENTRY Head =
&((PCLASS_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->ListHead;
if (Head->Flink != Head)
{
- /* We have at least one mouse */
+ /* We have at least one device */
PPORT_DEVICE_EXTENSION DevExt = CONTAINING_RECORD(Head->Flink,
PORT_DEVICE_EXTENSION, ListEntry);
IoGetCurrentIrpStackLocation(Irp)->MajorFunction =
IRP_MJ_INTERNAL_DEVICE_CONTROL;
IoSkipCurrentIrpStackLocation(Irp);
@@ -529,6 +529,9 @@
CONNECT_DATA ConnectData;
NTSTATUS Status;
+ DPRINT("Connecting PortDO %p [%wZ] to ClassDO %p\n",
+ PortDO, &PortDO->DriverObject->DriverName, ClassDO);
+
KeInitializeEvent(&Event, NotificationEvent, FALSE);
ConnectData.ClassDeviceObject = ClassDO;
@@ -564,6 +567,18 @@
}
return IoStatus.Status;
+}
+
+/* Send IOCTL_INTERNAL_*_DISCONNECT to port */
+static NTSTATUS
+DisconnectPortDriver(
+ IN PDEVICE_OBJECT PortDO)
+{
+ DPRINT("Disconnecting PortDO %p [%wZ]\n",
+ PortDO, &PortDO->DriverObject->DriverName);
+
+ DPRINT1("FIXME: Need to send IOCTL_INTERNAL_*_DISCONNECT\n");
+ return STATUS_NOT_IMPLEMENTED;
}
static NTSTATUS NTAPI
@@ -662,16 +677,17 @@
cleanup:
if (!(Fdo->Flags & DO_DEVICE_INITIALIZING))
- DPRINT1("FIXME: Need to send IOCTL_INTERNAL_*_DISCONNECT\n");
+ DisconnectPortDriver(Fdo);
if (DeviceExtension)
{
if (DeviceExtension->LowerDevice)
IoDetachDevice(DeviceExtension->LowerDevice);
- if (DriverExtension->ConnectMultiplePorts && DeviceExtension->ClassDO)
+ if (!DriverExtension->ConnectMultiplePorts && DeviceExtension->ClassDO)
{
PCLASS_DEVICE_EXTENSION ClassDeviceExtension;
ClassDeviceExtension =
(PCLASS_DEVICE_EXTENSION)DeviceExtension->ClassDO->DeviceExtension;
ExFreePool(ClassDeviceExtension->PortData);
+ IoDeleteDevice(DeviceExtension->ClassDO);
}
}
if (Fdo)