kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 7/9] staging: tidspbridge: fix memory leak
@ 2010-07-30 11:09 Kulikov Vasiliy
  2010-07-30 12:38 ` Nishanth Menon
  0 siblings, 1 reply; 2+ messages in thread
From: Kulikov Vasiliy @ 2010-07-30 11:09 UTC (permalink / raw)
  To: kernel-janitors
  Cc: Greg Kroah-Hartman, Rene Sapiens, Felipe Contreras,
	Nishanth Menon, Omar Ramirez Luna, devel, linux-kernel

dbll_create() leaks pzl_target if target_obj is NULL. Call kzalloc()
only if memory is used.

Signed-off-by: Kulikov Vasiliy <segooon@gmail.com>
---
 drivers/staging/tidspbridge/pmgr/dbll.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/tidspbridge/pmgr/dbll.c b/drivers/staging/tidspbridge/pmgr/dbll.c
index 3636aa3..86840ce 100644
--- a/drivers/staging/tidspbridge/pmgr/dbll.c
+++ b/drivers/staging/tidspbridge/pmgr/dbll.c
@@ -247,9 +247,9 @@ int dbll_create(struct dbll_tar_obj **target_obj,
 	DBC_REQUIRE(pattrs != NULL);
 	DBC_REQUIRE(target_obj != NULL);
 
-	/* Allocate DBL target object */
-	pzl_target = kzalloc(sizeof(struct dbll_tar_obj), GFP_KERNEL);
 	if (target_obj != NULL) {
+		/* Allocate DBL target object */
+		pzl_target = kzalloc(sizeof(struct dbll_tar_obj), GFP_KERNEL);
 		if (pzl_target = NULL) {
 			*target_obj = NULL;
 			status = -ENOMEM;
-- 
1.7.0.4


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

* Re: [PATCH 7/9] staging: tidspbridge: fix memory leak
  2010-07-30 11:09 [PATCH 7/9] staging: tidspbridge: fix memory leak Kulikov Vasiliy
@ 2010-07-30 12:38 ` Nishanth Menon
  0 siblings, 0 replies; 2+ messages in thread
From: Nishanth Menon @ 2010-07-30 12:38 UTC (permalink / raw)
  To: Kulikov Vasiliy
  Cc: kernel-janitors@vger.kernel.org, Greg Kroah-Hartman,
	Sapiens, Rene, Felipe Contreras, Ramirez Luna, Omar,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
	linux-omap@vger.kernel.org

Kulikov Vasiliy had written, on 07/30/2010 06:09 AM, the following:
> dbll_create() leaks pzl_target if target_obj is NULL. Call kzalloc()
> only if memory is used.
> 
> Signed-off-by: Kulikov Vasiliy <segooon@gmail.com>
> ---
>  drivers/staging/tidspbridge/pmgr/dbll.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/tidspbridge/pmgr/dbll.c b/drivers/staging/tidspbridge/pmgr/dbll.c
> index 3636aa3..86840ce 100644
> --- a/drivers/staging/tidspbridge/pmgr/dbll.c
> +++ b/drivers/staging/tidspbridge/pmgr/dbll.c
> @@ -247,9 +247,9 @@ int dbll_create(struct dbll_tar_obj **target_obj,
>  	DBC_REQUIRE(pattrs != NULL);
>  	DBC_REQUIRE(target_obj != NULL);
>  
> -	/* Allocate DBL target object */
> -	pzl_target = kzalloc(sizeof(struct dbll_tar_obj), GFP_KERNEL);
>  	if (target_obj != NULL) {
> +		/* Allocate DBL target object */
> +		pzl_target = kzalloc(sizeof(struct dbll_tar_obj), GFP_KERNEL);
>  		if (pzl_target = NULL) {
>  			*target_obj = NULL;
>  			status = -ENOMEM;
I would suggest to add a else branch for if (target_obj != NULL) adding 
a status =-ENOMEM if error.

Overall, I guess we need to kick out the DBC_REQUIRE usage.. it is 
misleading as it is active only when DEBUG macro is enabled!

-- 
Regards,
Nishanth Menon

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

end of thread, other threads:[~2010-07-30 12:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-30 11:09 [PATCH 7/9] staging: tidspbridge: fix memory leak Kulikov Vasiliy
2010-07-30 12:38 ` Nishanth Menon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).