summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2013-04-15 10:19:07 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-04-17 10:13:01 -0700
commitf4362867e047a254b745741d09fa68a583f50499 (patch)
treed058a1001785e9154991ace8fa07e45721a8c608 /drivers
parentfb86854109fdf1e843701df2d7126f89568ba850 (diff)
downloadlinux-f4362867e047a254b745741d09fa68a583f50499.tar.bz2
staging: comedi: unionxx5: fix memory leak during subdevice init
In the subdevice init during the attach of this driver, private data is allocated for each subdevice. The pointer to this data is then saved in the subdevice 's->private' so it can be free'ed during the detach. In __unioxx5_subdev_init() an error path exists that can happen before the allocated pointer is saved in s->private. Make sure the allocated memory is free'ed before returning the error. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/comedi/drivers/unioxx5.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/staging/comedi/drivers/unioxx5.c b/drivers/staging/comedi/drivers/unioxx5.c
index 1b19cc246ab2..0c243477cbe5 100644
--- a/drivers/staging/comedi/drivers/unioxx5.c
+++ b/drivers/staging/comedi/drivers/unioxx5.c
@@ -380,8 +380,10 @@ static int __unioxx5_subdev_init(struct comedi_device *dev,
return -ENOMEM;
ret = __comedi_request_region(dev, iobase, UNIOXX5_SIZE);
- if (ret)
+ if (ret) {
+ kfree(usp);
return ret;
+ }
usp->usp_iobase = iobase;
/* defining modules types */