mirror of
https://github.com/adulau/aha.git
synced 2025-01-04 23:23:18 +00:00
Input: sidewinder - fix memory leak
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>
This commit is contained in:
parent
f39b25bed3
commit
7363cfc866
1 changed files with 6 additions and 5 deletions
|
@ -589,7 +589,7 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv)
|
||||||
struct sw *sw;
|
struct sw *sw;
|
||||||
struct input_dev *input_dev;
|
struct input_dev *input_dev;
|
||||||
int i, j, k, l;
|
int i, j, k, l;
|
||||||
int err;
|
int err = 0;
|
||||||
unsigned char *buf = NULL; /* [SW_LENGTH] */
|
unsigned char *buf = NULL; /* [SW_LENGTH] */
|
||||||
unsigned char *idbuf = NULL; /* [SW_LENGTH] */
|
unsigned char *idbuf = NULL; /* [SW_LENGTH] */
|
||||||
unsigned char m = 1;
|
unsigned char m = 1;
|
||||||
|
@ -776,7 +776,10 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv)
|
||||||
goto fail4;
|
goto fail4;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
out: kfree(buf);
|
||||||
|
kfree(idbuf);
|
||||||
|
|
||||||
|
return err;
|
||||||
|
|
||||||
fail4: input_free_device(sw->dev[i]);
|
fail4: input_free_device(sw->dev[i]);
|
||||||
fail3: while (--i >= 0)
|
fail3: while (--i >= 0)
|
||||||
|
@ -784,9 +787,7 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv)
|
||||||
fail2: gameport_close(gameport);
|
fail2: gameport_close(gameport);
|
||||||
fail1: gameport_set_drvdata(gameport, NULL);
|
fail1: gameport_set_drvdata(gameport, NULL);
|
||||||
kfree(sw);
|
kfree(sw);
|
||||||
kfree(buf);
|
goto out;
|
||||||
kfree(idbuf);
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sw_disconnect(struct gameport *gameport)
|
static void sw_disconnect(struct gameport *gameport)
|
||||||
|
|
Loading…
Reference in a new issue