linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [mdadm PATCH] Fix small memory leak
@ 2011-08-26  5:33 Thomas Jarosch
  2011-09-07  8:11 ` NeilBrown
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Jarosch @ 2011-08-26  5:33 UTC (permalink / raw)
  To: linux-raid

Found by cppcheck

Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com>
---
 config.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/config.c b/config.c
index ad75411..c0a6baa 100644
--- a/config.c
+++ b/config.c
@@ -707,6 +707,8 @@ void autoline(char *line)
 	for (i = 0; i < super_cnt; i++)
 		if (!seen[i])
 			policy_add(rule_policy, pol_auto, dflt, pol_metadata, superlist[i]->name, NULL);
+
+	free(seen);
 }
 
 int loaded = 0;
-- 
1.7.4.4


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

* Re: [mdadm PATCH] Fix small memory leak
  2011-08-26  5:33 [mdadm PATCH] Fix small memory leak Thomas Jarosch
@ 2011-09-07  8:11 ` NeilBrown
  0 siblings, 0 replies; 4+ messages in thread
From: NeilBrown @ 2011-09-07  8:11 UTC (permalink / raw)
  To: Thomas Jarosch; +Cc: linux-raid

On Fri, 26 Aug 2011 07:33:37 +0200 Thomas Jarosch
<thomas.jarosch@intra2net.com> wrote:

> Found by cppcheck
> 
> Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com>
> ---
>  config.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/config.c b/config.c
> index ad75411..c0a6baa 100644
> --- a/config.c
> +++ b/config.c
> @@ -707,6 +707,8 @@ void autoline(char *line)
>  	for (i = 0; i < super_cnt; i++)
>  		if (!seen[i])
>  			policy_add(rule_policy, pol_auto, dflt, pol_metadata, superlist[i]->name, NULL);
> +
> +	free(seen);
>  }
>  
>  int loaded = 0;


Applied, thanks.

NeilBrown

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

* [mdadm PATCH] Fix small memory leak
@ 2011-10-02 19:45 Thomas Jarosch
  2011-10-02 21:31 ` NeilBrown
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Jarosch @ 2011-10-02 19:45 UTC (permalink / raw)
  To: linux-raid; +Cc: Neil Brown

Credit goes to cppcheck.

Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com>
---
 policy.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/policy.c b/policy.c
index 2bbbac8..4a6ef82 100644
--- a/policy.c
+++ b/policy.c
@@ -757,8 +757,10 @@ int policy_check_path(struct mdinfo *disk, struct map_ent *array)
 
 	snprintf(path, PATH_MAX, FAILED_SLOTS_DIR "/%s", id_path);
 	f = fopen(path, "r");
-	if (!f)
+	if (!f) {
+		free(id_path);
 		return 0;
+	}
 
 	rv = fscanf(f, " %s %x:%x:%x:%x\n",
 		    array->metadata,
@@ -767,6 +769,7 @@ int policy_check_path(struct mdinfo *disk, struct map_ent *array)
 		    array->uuid+2,
 		    array->uuid+3);
 	fclose(f);
+	free(id_path);
 	return rv == 5;
 }
 
-- 
1.7.4.4


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

* Re: [mdadm PATCH] Fix small memory leak
  2011-10-02 19:45 Thomas Jarosch
@ 2011-10-02 21:31 ` NeilBrown
  0 siblings, 0 replies; 4+ messages in thread
From: NeilBrown @ 2011-10-02 21:31 UTC (permalink / raw)
  To: Thomas Jarosch; +Cc: linux-raid

[-- Attachment #1: Type: text/plain, Size: 958 bytes --]

On Sun, 02 Oct 2011 21:45:41 +0200 Thomas Jarosch
<thomas.jarosch@intra2net.com> wrote:

> Credit goes to cppcheck.
> 
> Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com>
> ---
>  policy.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/policy.c b/policy.c
> index 2bbbac8..4a6ef82 100644
> --- a/policy.c
> +++ b/policy.c
> @@ -757,8 +757,10 @@ int policy_check_path(struct mdinfo *disk, struct map_ent *array)
>  
>  	snprintf(path, PATH_MAX, FAILED_SLOTS_DIR "/%s", id_path);
>  	f = fopen(path, "r");
> -	if (!f)
> +	if (!f) {
> +		free(id_path);
>  		return 0;
> +	}
>  
>  	rv = fscanf(f, " %s %x:%x:%x:%x\n",
>  		    array->metadata,
> @@ -767,6 +769,7 @@ int policy_check_path(struct mdinfo *disk, struct map_ent *array)
>  		    array->uuid+2,
>  		    array->uuid+3);
>  	fclose(f);
> +	free(id_path);
>  	return rv == 5;
>  }
>  


applied.  Thanks.

NeilBrown

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 190 bytes --]

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

end of thread, other threads:[~2011-10-02 21:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-26  5:33 [mdadm PATCH] Fix small memory leak Thomas Jarosch
2011-09-07  8:11 ` NeilBrown
  -- strict thread matches above, loose matches on Subject: below --
2011-10-02 19:45 Thomas Jarosch
2011-10-02 21:31 ` NeilBrown

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