Skip to content

Commit

Permalink
Input: sidewinder - fix memory leak
Browse files Browse the repository at this point in the history
In sw_connect we leak 'buf' and 'idbuf' when we do not leave via one of
the fail* labels. This was spotted by the coverity checker.

Patch is compile tested only due to lack of hardware.

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
  • Loading branch information
Jesper Juhl authored and Dmitry Torokhov committed May 30, 2006
1 parent f39b25b commit 7363cfc
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions drivers/input/joystick/sidewinder.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv)
struct sw *sw;
struct input_dev *input_dev;
int i, j, k, l;
int err;
int err = 0;
unsigned char *buf = NULL; /* [SW_LENGTH] */
unsigned char *idbuf = NULL; /* [SW_LENGTH] */
unsigned char m = 1;
Expand Down Expand Up @@ -776,17 +776,18 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv)
goto fail4;
}

return 0;
out: kfree(buf);
kfree(idbuf);

return err;

fail4: input_free_device(sw->dev[i]);
fail3: while (--i >= 0)
input_unregister_device(sw->dev[i]);
fail2: gameport_close(gameport);
fail1: gameport_set_drvdata(gameport, NULL);
kfree(sw);
kfree(buf);
kfree(idbuf);
return err;
goto out;
}

static void sw_disconnect(struct gameport *gameport)
Expand Down

0 comments on commit 7363cfc

Please sign in to comment.