public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] davinci: don't return under lock on error path
@ 2010-04-07  9:21 Dan Carpenter
  2010-04-07  9:25 ` Hiremath, Vaibhav
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2010-04-07  9:21 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Hans Verkuil, Vaibhav Hiremath, Laurent Pinchart,
	Muralidharan Karicheri, linux-media, kernel-janitors

If the kmalloc() failed for "ccdc_cfg = kmalloc(...);" then we would exit
with the lock held.  I moved the mutex_lock() below the allocation
because it isn't protecting anything in that block and allocations are 
allocations are sometimes slow.

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/drivers/media/video/davinci/vpfe_capture.c b/drivers/media/video/davinci/vpfe_capture.c
index 7cf042f..5c83f90 100644
--- a/drivers/media/video/davinci/vpfe_capture.c
+++ b/drivers/media/video/davinci/vpfe_capture.c
@@ -1824,7 +1824,6 @@ static __init int vpfe_probe(struct platform_device *pdev)
 		goto probe_free_dev_mem;
 	}
 
-	mutex_lock(&ccdc_lock);
 	/* Allocate memory for ccdc configuration */
 	ccdc_cfg = kmalloc(sizeof(struct ccdc_config), GFP_KERNEL);
 	if (NULL == ccdc_cfg) {
@@ -1833,6 +1832,8 @@ static __init int vpfe_probe(struct platform_device *pdev)
 		goto probe_free_dev_mem;
 	}
 
+	mutex_lock(&ccdc_lock);
+
 	strncpy(ccdc_cfg->name, vpfe_cfg->ccdc, 32);
 	/* Get VINT0 irq resource */
 	res1 = platform_get_resource(pdev, IORESOURCE_IRQ, 0);

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: [patch] davinci: don't return under lock on error path
  2010-04-07  9:21 [patch] davinci: don't return under lock on error path Dan Carpenter
@ 2010-04-07  9:25 ` Hiremath, Vaibhav
  0 siblings, 0 replies; 2+ messages in thread
From: Hiremath, Vaibhav @ 2010-04-07  9:25 UTC (permalink / raw)
  To: Dan Carpenter, Mauro Carvalho Chehab
  Cc: Hans Verkuil, Laurent Pinchart, Karicheri, Muralidharan,
	linux-media@vger.kernel.org, kernel-janitors@vger.kernel.org


> -----Original Message-----
> From: Dan Carpenter [mailto:error27@gmail.com]
> Sent: Wednesday, April 07, 2010 2:51 PM
> To: Mauro Carvalho Chehab
> Cc: Hans Verkuil; Hiremath, Vaibhav; Laurent Pinchart; Karicheri,
> Muralidharan; linux-media@vger.kernel.org; kernel-janitors@vger.kernel.org
> Subject: [patch] davinci: don't return under lock on error path
> 
> If the kmalloc() failed for "ccdc_cfg = kmalloc(...);" then we would exit
> with the lock held.  I moved the mutex_lock() below the allocation
> because it isn't protecting anything in that block and allocations are
> allocations are sometimes slow.
[Hiremath, Vaibhav] Good catch and thanks for the patch.


Acked-by: Vaibhav Hiremath <hvaibhav@ti.com>

Thanks,
Vaibhav
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> 
> diff --git a/drivers/media/video/davinci/vpfe_capture.c
> b/drivers/media/video/davinci/vpfe_capture.c
> index 7cf042f..5c83f90 100644
> --- a/drivers/media/video/davinci/vpfe_capture.c
> +++ b/drivers/media/video/davinci/vpfe_capture.c
> @@ -1824,7 +1824,6 @@ static __init int vpfe_probe(struct platform_device
> *pdev)
>  		goto probe_free_dev_mem;
>  	}
> 
> -	mutex_lock(&ccdc_lock);
>  	/* Allocate memory for ccdc configuration */
>  	ccdc_cfg = kmalloc(sizeof(struct ccdc_config), GFP_KERNEL);
>  	if (NULL == ccdc_cfg) {
> @@ -1833,6 +1832,8 @@ static __init int vpfe_probe(struct platform_device
> *pdev)
>  		goto probe_free_dev_mem;
>  	}
> 
> +	mutex_lock(&ccdc_lock);
> +
>  	strncpy(ccdc_cfg->name, vpfe_cfg->ccdc, 32);
>  	/* Get VINT0 irq resource */
>  	res1 = platform_get_resource(pdev, IORESOURCE_IRQ, 0);

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-04-07  9:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-07  9:21 [patch] davinci: don't return under lock on error path Dan Carpenter
2010-04-07  9:25 ` Hiremath, Vaibhav

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox