diff options
author | NeilBrown <neilb@suse.de> | 2009-10-22 02:00:56 +0200 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2009-10-22 02:00:56 +0200 |
commit | 0eb26465c0a14d707ca00f4f7bcdb67bde36f706 (patch) | |
tree | 60ccd8c30d747fce5a40926cddf6af0a1e9531d4 /mdopen.c | |
parent | super-intel: Fix compilation of mdassemble. (diff) | |
download | mdadm-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.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -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); } |