V4L/DVB: soc-camera: module_put() fix

Message ID 20100705101259.23155.79936.sendpatchset@t400s (mailing list archive)
State Superseded, archived
Headers

Commit Message

Magnus Damm July 5, 2010, 10:12 a.m. UTC
  From: Magnus Damm <damm@opensource.se>

Avoid calling module_put() if try_module_get() has
been skipped.

Signed-off-by: Magnus Damm <damm@opensource.se>
---

 drivers/media/video/soc_camera.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--
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
  

Comments

Guennadi Liakhovetski July 5, 2010, 7:58 p.m. UTC | #1
On Mon, 5 Jul 2010, Magnus Damm wrote:

> From: Magnus Damm <damm@opensource.se>
> 
> Avoid calling module_put() if try_module_get() has
> been skipped.
> 
> Signed-off-by: Magnus Damm <damm@opensource.se>
> ---
> 
>  drivers/media/video/soc_camera.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> --- 0001/drivers/media/video/soc_camera.c
> +++ work/drivers/media/video/soc_camera.c	2010-06-23 13:43:05.000000000 +0900
> @@ -1034,7 +1034,8 @@ eiufmt:
>  		soc_camera_free_i2c(icd);
>  	} else {
>  		icl->del_device(icl);
> -		module_put(control->driver->owner);
> +		if (control && control->driver && control->driver->owner)
> +			module_put(control->driver->owner);
>  	}
>  enodrv:
>  eadddev:

Hm, don't understand. I don't see how this can be a problem. Have you hit 
a case, when you enter this path with one of those pointers == NULL? 
Looking at the code, this is only entered from eiufmt or evidstart "if 
(!icl->board_info)" (i.e., only with the soc_camera_platform driver). And 
if you got down to one of those errors, you do have all those pointers in 
place. What am I missing?

Thanks
Guennadi
---
Guennadi Liakhovetski
--
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

--- 0001/drivers/media/video/soc_camera.c
+++ work/drivers/media/video/soc_camera.c	2010-06-23 13:43:05.000000000 +0900
@@ -1034,7 +1034,8 @@  eiufmt:
 		soc_camera_free_i2c(icd);
 	} else {
 		icl->del_device(icl);
-		module_put(control->driver->owner);
+		if (control && control->driver && control->driver->owner)
+			module_put(control->driver->owner);
 	}
 enodrv:
 eadddev: