Commit 1f2d5f71 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] fix init/do_mounts_rd.c memory leak

From: Hollis Blanchard <hollis@austin.ibm.com>

Another potential memory leak the Stanford checker caught at 2.5.48: while
closing and opening floppy disks, buf could be allocated and never freed.
parent e03dd6bd
...@@ -129,7 +129,7 @@ int __init rd_load_image(char *from) ...@@ -129,7 +129,7 @@ int __init rd_load_image(char *from)
int in_fd, out_fd; int in_fd, out_fd;
unsigned long rd_blocks, devblocks; unsigned long rd_blocks, devblocks;
int nblocks, i, disk; int nblocks, i, disk;
char *buf; char *buf = NULL;
unsigned short rotate = 0; unsigned short rotate = 0;
#if !defined(CONFIG_ARCH_S390) && !defined(CONFIG_PPC_ISERIES) #if !defined(CONFIG_ARCH_S390) && !defined(CONFIG_PPC_ISERIES)
char rotator[4] = { '|' , '/' , '-' , '\\' }; char rotator[4] = { '|' , '/' , '-' , '\\' };
...@@ -226,7 +226,6 @@ int __init rd_load_image(char *from) ...@@ -226,7 +226,6 @@ int __init rd_load_image(char *from)
#endif #endif
} }
printk("done.\n"); printk("done.\n");
kfree(buf);
successful_load: successful_load:
res = 1; res = 1;
...@@ -235,6 +234,7 @@ int __init rd_load_image(char *from) ...@@ -235,6 +234,7 @@ int __init rd_load_image(char *from)
noclose_input: noclose_input:
close(out_fd); close(out_fd);
out: out:
kfree(buf);
sys_unlink("/dev/ram"); sys_unlink("/dev/ram");
return res; return res;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment