summaryrefslogtreecommitdiffstats
path: root/drivers/media/video/omap3isp/ispstat.c
diff options
context:
space:
mode:
authorLaurent Pinchart2011-09-22 22:10:30 +0200
committerMauro Carvalho Chehab2011-11-03 21:33:46 +0100
commit9b6390bd95c65ad4a6c650955fa1e3f18f8a540c (patch)
tree3e1dcd35d28f0793dd62d1a3ff72b4831890a118 /drivers/media/video/omap3isp/ispstat.c
parent[media] omap3isp: Add missing mutex_destroy() calls (diff)
downloadkernel-qcow2-linux-9b6390bd95c65ad4a6c650955fa1e3f18f8a540c.tar.gz
kernel-qcow2-linux-9b6390bd95c65ad4a6c650955fa1e3f18f8a540c.tar.xz
kernel-qcow2-linux-9b6390bd95c65ad4a6c650955fa1e3f18f8a540c.zip
[media] omap3isp: Fix memory leaks in initialization error paths
Make sure all modules init functions clean up after themselves in case of error. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reported-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/omap3isp/ispstat.c')
-rw-r--r--drivers/media/video/omap3isp/ispstat.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/media/video/omap3isp/ispstat.c b/drivers/media/video/omap3isp/ispstat.c
index 28b7cc61cba6..68d539456c55 100644
--- a/drivers/media/video/omap3isp/ispstat.c
+++ b/drivers/media/video/omap3isp/ispstat.c
@@ -1074,14 +1074,23 @@ static int isp_stat_init_entities(struct ispstat *stat, const char *name,
int omap3isp_stat_init(struct ispstat *stat, const char *name,
const struct v4l2_subdev_ops *sd_ops)
{
+ int ret;
+
stat->buf = kcalloc(STAT_MAX_BUFS, sizeof(*stat->buf), GFP_KERNEL);
if (!stat->buf)
return -ENOMEM;
+
isp_stat_buf_clear(stat);
mutex_init(&stat->ioctl_lock);
atomic_set(&stat->buf_err, 0);
- return isp_stat_init_entities(stat, name, sd_ops);
+ ret = isp_stat_init_entities(stat, name, sd_ops);
+ if (ret < 0) {
+ mutex_destroy(&stat->ioctl_lock);
+ kfree(stat->buf);
+ }
+
+ return ret;
}
void omap3isp_stat_cleanup(struct ispstat *stat)