[-,FIX] V4L: vpfe_capture - free ccdc_lock when memory allocation fails

Message ID 1268165298-31094-1-git-send-email-m-karicheri2@ti.com (mailing list archive)
State Superseded, archived
Headers

Commit Message

m-karicheri2@ti.com March 9, 2010, 8:08 p.m. UTC
  From: Murali Karicheri <m-karicheri2@ti.com>

This patch fixes a bug in vpfe_probe() that doesn't call mutex_unlock() if memory
allocation for ccdc_cfg fails. See also the smatch warning report from Dan
Carpenter that shows this as an issue.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
---
 drivers/media/video/davinci/vpfe_capture.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
  

Comments

m-karicheri2@ti.com March 10, 2010, 4:19 p.m. UTC | #1
Hi,

If there are no comments, I will send a pull request for merging this.

Murali Karicheri
Software Design Engineer
Texas Instruments Inc.
Germantown, MD 20874
phone: 301-407-9583
email: m-karicheri2@ti.com

>-----Original Message-----
>From: Karicheri, Muralidharan
>Sent: Tuesday, March 09, 2010 3:08 PM
>To: linux-media@vger.kernel.org
>Cc: Karicheri, Muralidharan
>Subject: [PATCH - FIX] V4L: vpfe_capture - free ccdc_lock when memory
>allocation fails
>
>From: Murali Karicheri <m-karicheri2@ti.com>
>
>This patch fixes a bug in vpfe_probe() that doesn't call mutex_unlock() if
>memory
>allocation for ccdc_cfg fails. See also the smatch warning report from Dan
>Carpenter that shows this as an issue.
>
>Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
>---
> drivers/media/video/davinci/vpfe_capture.c |    5 +++--
> 1 files changed, 3 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/media/video/davinci/vpfe_capture.c
>b/drivers/media/video/davinci/vpfe_capture.c
>index 885cd54..91f665b 100644
>--- a/drivers/media/video/davinci/vpfe_capture.c
>+++ b/drivers/media/video/davinci/vpfe_capture.c
>@@ -1829,7 +1829,7 @@ static __init int vpfe_probe(struct platform_device
>*pdev)
> 	if (NULL == ccdc_cfg) {
> 		v4l2_err(pdev->dev.driver,
> 			 "Memory allocation failed for ccdc_cfg\n");
>-		goto probe_free_dev_mem;
>+		goto probe_free_lock;
> 	}
>
> 	strncpy(ccdc_cfg->name, vpfe_cfg->ccdc, 32);
>@@ -1981,8 +1981,9 @@ probe_out_video_release:
> probe_out_release_irq:
> 	free_irq(vpfe_dev->ccdc_irq0, vpfe_dev);
> probe_free_ccdc_cfg_mem:
>-	mutex_unlock(&ccdc_lock);
> 	kfree(ccdc_cfg);
>+probe_free_lock:
>+	mutex_unlock(&ccdc_lock);
> probe_free_dev_mem:
> 	kfree(vpfe_dev);
> 	return ret;
>--
>1.6.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
  

Patch

diff --git a/drivers/media/video/davinci/vpfe_capture.c b/drivers/media/video/davinci/vpfe_capture.c
index 885cd54..91f665b 100644
--- a/drivers/media/video/davinci/vpfe_capture.c
+++ b/drivers/media/video/davinci/vpfe_capture.c
@@ -1829,7 +1829,7 @@  static __init int vpfe_probe(struct platform_device *pdev)
 	if (NULL == ccdc_cfg) {
 		v4l2_err(pdev->dev.driver,
 			 "Memory allocation failed for ccdc_cfg\n");
-		goto probe_free_dev_mem;
+		goto probe_free_lock;
 	}
 
 	strncpy(ccdc_cfg->name, vpfe_cfg->ccdc, 32);
@@ -1981,8 +1981,9 @@  probe_out_video_release:
 probe_out_release_irq:
 	free_irq(vpfe_dev->ccdc_irq0, vpfe_dev);
 probe_free_ccdc_cfg_mem:
-	mutex_unlock(&ccdc_lock);
 	kfree(ccdc_cfg);
+probe_free_lock:
+	mutex_unlock(&ccdc_lock);
 probe_free_dev_mem:
 	kfree(vpfe_dev);
 	return ret;