summaryrefslogtreecommitdiffstats
path: root/mdopen.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2009-10-22 02:00:56 +0200
committerNeilBrown <neilb@suse.de>2009-10-22 02:00:56 +0200
commit0eb26465c0a14d707ca00f4f7bcdb67bde36f706 (patch)
tree60ccd8c30d747fce5a40926cddf6af0a1e9531d4 /mdopen.c
parentsuper-intel: Fix compilation of mdassemble. (diff)
downloadmdadm-0eb26465c0a14d707ca00f4f7bcdb67bde36f706.tar.xz
mdadm-0eb26465c0a14d707ca00f4f7bcdb67bde36f706.zip
Free some malloced memory that wasn't being freed.
As mdadm is normally a short-lived program it isn't always necessary to free memory that was allocated, as the 'exit()' call will automatically free everything. But it is more obviously correct if the 'free' is there. So this patch add a few calls to 'free' Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'mdopen.c')
-rw-r--r--mdopen.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/mdopen.c b/mdopen.c
index ed53d6f3..21baf5da 100644
--- a/mdopen.c
+++ b/mdopen.c
@@ -43,7 +43,7 @@ void make_parts(char *dev, int cnt)
int odig = odig; /* quiet gcc -Os unitialized warning */
int i;
int nlen = strlen(dev) + 20;
- char *name = malloc(nlen);
+ char *name;
int dig = isdigit(dev[strlen(dev)-1]);
char orig[1024];
char sym[1024];
@@ -52,6 +52,7 @@ void make_parts(char *dev, int cnt)
if (cnt==0) cnt=4;
if (lstat(dev, &stb)!= 0)
return;
+
if (S_ISLNK(stb.st_mode)) {
int len = readlink(dev, orig, sizeof(orig));
if (len < 0 || len > 1000)
@@ -63,6 +64,7 @@ void make_parts(char *dev, int cnt)
minor_num = minor(stb.st_rdev);
} else
return;
+ name = malloc(nlen);
for (i=1; i <= cnt ; i++) {
struct stat stb2;
snprintf(name, nlen, "%s%s%d", dev, dig?"p":"", i);
@@ -92,6 +94,7 @@ void make_parts(char *dev, int cnt)
if (err == 0 && stat(name, &stb2) == 0)
add_dev(name, &stb2, 0, NULL);
}
+ free(name);
}