Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 98b7fb04 authored by Dmitry Torokhov's avatar Dmitry Torokhov
Browse files

Input: iforce - fix oops on device disconnect



Do not try to free iforce device when we closing input device; disconnect
is the only place where it should be deleted.

Reported-by: default avatarJohannes Ebke <johannes.ebke@physik.uni-muenchen.de>
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent 94ec26c8
Loading
Loading
Loading
Loading
+5 −21
Original line number Original line Diff line number Diff line
@@ -210,7 +210,7 @@ static int iforce_open(struct input_dev *dev)
	return 0;
	return 0;
}
}


static void iforce_release(struct input_dev *dev)
static void iforce_close(struct input_dev *dev)
{
{
	struct iforce *iforce = input_get_drvdata(dev);
	struct iforce *iforce = input_get_drvdata(dev);
	int i;
	int i;
@@ -234,24 +234,8 @@ static void iforce_release(struct input_dev *dev)
#ifdef CONFIG_JOYSTICK_IFORCE_USB
#ifdef CONFIG_JOYSTICK_IFORCE_USB
	case IFORCE_USB:
	case IFORCE_USB:
		usb_kill_urb(iforce->irq);
		usb_kill_urb(iforce->irq);

		usb_kill_urb(iforce->out);
			/* The device was unplugged before the file
		usb_kill_urb(iforce->ctrl);
			 * was released */
			if (iforce->usbdev == NULL) {
				iforce_delete_device(iforce);
				kfree(iforce);
			}
		break;
#endif
	}
}

void iforce_delete_device(struct iforce *iforce)
{
	switch (iforce->bus) {
#ifdef CONFIG_JOYSTICK_IFORCE_USB
	case IFORCE_USB:
		iforce_usb_delete(iforce);
		break;
		break;
#endif
#endif
#ifdef CONFIG_JOYSTICK_IFORCE_232
#ifdef CONFIG_JOYSTICK_IFORCE_232
@@ -303,7 +287,7 @@ int iforce_init_device(struct iforce *iforce)


	input_dev->name = "Unknown I-Force device";
	input_dev->name = "Unknown I-Force device";
	input_dev->open = iforce_open;
	input_dev->open = iforce_open;
	input_dev->close = iforce_release;
	input_dev->close = iforce_close;


/*
/*
 * On-device memory allocation.
 * On-device memory allocation.
+7 −21
Original line number Original line Diff line number Diff line
@@ -186,34 +186,20 @@ static int iforce_usb_probe(struct usb_interface *intf,
	return err;
	return err;
}
}


/* Called by iforce_delete() */
void iforce_usb_delete(struct iforce* iforce)
{
	usb_kill_urb(iforce->irq);
	usb_kill_urb(iforce->out);
	usb_kill_urb(iforce->ctrl);

	usb_free_urb(iforce->irq);
	usb_free_urb(iforce->out);
	usb_free_urb(iforce->ctrl);
}

static void iforce_usb_disconnect(struct usb_interface *intf)
static void iforce_usb_disconnect(struct usb_interface *intf)
{
{
	struct iforce *iforce = usb_get_intfdata(intf);
	struct iforce *iforce = usb_get_intfdata(intf);
	int open = 0; /* FIXME! iforce->dev.handle->open; */


	usb_set_intfdata(intf, NULL);
	usb_set_intfdata(intf, NULL);
	if (iforce) {

		iforce->usbdev = NULL;
	input_unregister_device(iforce->dev);
	input_unregister_device(iforce->dev);


		if (!open) {
	usb_free_urb(iforce->irq);
			iforce_delete_device(iforce);
	usb_free_urb(iforce->out);
	usb_free_urb(iforce->ctrl);

	kfree(iforce);
	kfree(iforce);
}
}
	}
}


static struct usb_device_id iforce_usb_ids [] = {
static struct usb_device_id iforce_usb_ids [] = {
	{ USB_DEVICE(0x044f, 0xa01c) },		/* Thrustmaster Motor Sport GT */
	{ USB_DEVICE(0x044f, 0xa01c) },		/* Thrustmaster Motor Sport GT */
+0 −2
Original line number Original line Diff line number Diff line
@@ -150,11 +150,9 @@ void iforce_serial_xmit(struct iforce *iforce);


/* iforce-usb.c */
/* iforce-usb.c */
void iforce_usb_xmit(struct iforce *iforce);
void iforce_usb_xmit(struct iforce *iforce);
void iforce_usb_delete(struct iforce *iforce);


/* iforce-main.c */
/* iforce-main.c */
int iforce_init_device(struct iforce *iforce);
int iforce_init_device(struct iforce *iforce);
void iforce_delete_device(struct iforce *iforce);


/* iforce-packets.c */
/* iforce-packets.c */
int iforce_control_playback(struct iforce*, u16 id, unsigned int);
int iforce_control_playback(struct iforce*, u16 id, unsigned int);