Skip to content

Commit 9d3bef0

Browse files
mergedtor
authored andcommitted
Input: pegasus_notetaker - fix usb_autopm calls to be balanced
We should only "put" the interface if submitting URB or setting tablet mode in pegasus_open() fails, otherwise leave it to pegasus_close(). Signed-off-by: Martin Kepplinger <[email protected]> Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 168c139 commit 9d3bef0

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

drivers/input/tablet/pegasus_notetaker.c

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -209,34 +209,39 @@ static void pegasus_init(struct work_struct *work)
209209
static int pegasus_open(struct input_dev *dev)
210210
{
211211
struct pegasus *pegasus = input_get_drvdata(dev);
212-
int retval;
212+
int error;
213213

214-
retval = usb_autopm_get_interface(pegasus->intf);
215-
if (retval)
216-
return retval;
214+
error = usb_autopm_get_interface(pegasus->intf);
215+
if (error)
216+
return error;
217217

218218
pegasus->irq->dev = pegasus->usbdev;
219-
if (usb_submit_urb(pegasus->irq, GFP_KERNEL))
220-
retval = -EIO;
219+
if (usb_submit_urb(pegasus->irq, GFP_KERNEL)) {
220+
error = -EIO;
221+
goto err_autopm_put;
222+
}
223+
224+
error = pegasus_set_mode(pegasus, PEN_MODE_XY, NOTETAKER_LED_MOUSE);
225+
if (error)
226+
goto err_kill_urb;
221227

222-
retval = pegasus_set_mode(pegasus, PEN_MODE_XY, NOTETAKER_LED_MOUSE);
228+
return 0;
223229

230+
err_kill_urb:
231+
usb_kill_urb(pegasus->irq);
232+
cancel_work_sync(&pegasus->init);
233+
err_autopm_put:
224234
usb_autopm_put_interface(pegasus->intf);
225-
226-
return retval;
235+
return error;
227236
}
228237

229238
static void pegasus_close(struct input_dev *dev)
230239
{
231240
struct pegasus *pegasus = input_get_drvdata(dev);
232-
int autopm_error;
233241

234-
autopm_error = usb_autopm_get_interface(pegasus->intf);
235242
usb_kill_urb(pegasus->irq);
236243
cancel_work_sync(&pegasus->init);
237-
238-
if (!autopm_error)
239-
usb_autopm_put_interface(pegasus->intf);
244+
usb_autopm_put_interface(pegasus->intf);
240245
}
241246

242247
static int pegasus_probe(struct usb_interface *intf,

0 commit comments

Comments
 (0)