diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2011-09-22 16:10:30 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-11-03 16:33:46 -0400 |
commit | 9b6390bd95c65ad4a6c650955fa1e3f18f8a540c (patch) | |
tree | 3e1dcd35d28f0793dd62d1a3ff72b4831890a118 /drivers/media/video/omap3isp/ispccdc.c | |
parent | ed33ac8e0876a3016511ea0aaf9af1d965ee2c44 (diff) |
[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/ispccdc.c')
-rw-r--r-- | drivers/media/video/omap3isp/ispccdc.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/drivers/media/video/omap3isp/ispccdc.c b/drivers/media/video/omap3isp/ispccdc.c index 3a43be2f5452..6330b1d57b1e 100644 --- a/drivers/media/video/omap3isp/ispccdc.c +++ b/drivers/media/video/omap3isp/ispccdc.c | |||
@@ -2224,15 +2224,21 @@ static int ccdc_init_entities(struct isp_ccdc_device *ccdc) | |||
2224 | 2224 | ||
2225 | ret = omap3isp_video_init(&ccdc->video_out, "CCDC"); | 2225 | ret = omap3isp_video_init(&ccdc->video_out, "CCDC"); |
2226 | if (ret < 0) | 2226 | if (ret < 0) |
2227 | return ret; | 2227 | goto error_video; |
2228 | 2228 | ||
2229 | /* Connect the CCDC subdev to the video node. */ | 2229 | /* Connect the CCDC subdev to the video node. */ |
2230 | ret = media_entity_create_link(&ccdc->subdev.entity, CCDC_PAD_SOURCE_OF, | 2230 | ret = media_entity_create_link(&ccdc->subdev.entity, CCDC_PAD_SOURCE_OF, |
2231 | &ccdc->video_out.video.entity, 0, 0); | 2231 | &ccdc->video_out.video.entity, 0, 0); |
2232 | if (ret < 0) | 2232 | if (ret < 0) |
2233 | return ret; | 2233 | goto error_link; |
2234 | 2234 | ||
2235 | return 0; | 2235 | return 0; |
2236 | |||
2237 | error_link: | ||
2238 | omap3isp_video_cleanup(&ccdc->video_out); | ||
2239 | error_video: | ||
2240 | media_entity_cleanup(me); | ||
2241 | return ret; | ||
2236 | } | 2242 | } |
2237 | 2243 | ||
2238 | /* | 2244 | /* |
@@ -2246,6 +2252,7 @@ static int ccdc_init_entities(struct isp_ccdc_device *ccdc) | |||
2246 | int omap3isp_ccdc_init(struct isp_device *isp) | 2252 | int omap3isp_ccdc_init(struct isp_device *isp) |
2247 | { | 2253 | { |
2248 | struct isp_ccdc_device *ccdc = &isp->isp_ccdc; | 2254 | struct isp_ccdc_device *ccdc = &isp->isp_ccdc; |
2255 | int ret; | ||
2249 | 2256 | ||
2250 | spin_lock_init(&ccdc->lock); | 2257 | spin_lock_init(&ccdc->lock); |
2251 | init_waitqueue_head(&ccdc->wait); | 2258 | init_waitqueue_head(&ccdc->wait); |
@@ -2274,7 +2281,13 @@ int omap3isp_ccdc_init(struct isp_device *isp) | |||
2274 | ccdc->update = OMAP3ISP_CCDC_BLCLAMP; | 2281 | ccdc->update = OMAP3ISP_CCDC_BLCLAMP; |
2275 | ccdc_apply_controls(ccdc); | 2282 | ccdc_apply_controls(ccdc); |
2276 | 2283 | ||
2277 | return ccdc_init_entities(ccdc); | 2284 | ret = ccdc_init_entities(ccdc); |
2285 | if (ret < 0) { | ||
2286 | mutex_destroy(&ccdc->ioctl_lock); | ||
2287 | return ret; | ||
2288 | } | ||
2289 | |||
2290 | return 0; | ||
2278 | } | 2291 | } |
2279 | 2292 | ||
2280 | /* | 2293 | /* |