summaryrefslogtreecommitdiff
path: root/drivers/media/video/omap3isp/ispstat.c
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2011-09-23 00:10:30 +0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-11-04 00:33:46 +0400
commit9b6390bd95c65ad4a6c650955fa1e3f18f8a540c (patch)
tree3e1dcd35d28f0793dd62d1a3ff72b4831890a118 /drivers/media/video/omap3isp/ispstat.c
parented33ac8e0876a3016511ea0aaf9af1d965ee2c44 (diff)
downloadlinux-9b6390bd95c65ad4a6c650955fa1e3f18f8a540c.tar.xz
[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)