Commit 3265e66b authored by Thomas Petazzoni's avatar Thomas Petazzoni Committed by Linus Torvalds

directly use kmalloc() and kfree() in init/initramfs.c

Instead of using the malloc() and free() wrappers needed by the
lib/inflate.c code for allocations, simply use kmalloc() and kfree() in the
initramfs code.  This is needed for a further lib/inflate.c-related cleanup
patch that will remove the malloc() and free() functions.

Take that opportunity to remove the useless kmalloc() return value
cast.

Based on work done by Matt Mackall.
Signed-off-by: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: default avatarMatt Mackall <mpm@selenic.com>
Cc: Jan Engelhardt <jengelh@computergmbh.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 5f97a5a8
...@@ -57,7 +57,7 @@ static char __init *find_link(int major, int minor, int ino, ...@@ -57,7 +57,7 @@ static char __init *find_link(int major, int minor, int ino,
continue; continue;
return (*p)->name; return (*p)->name;
} }
q = (struct hash *)malloc(sizeof(struct hash)); q = kmalloc(sizeof(struct hash), GFP_KERNEL);
if (!q) if (!q)
panic("can't allocate link hash entry"); panic("can't allocate link hash entry");
q->major = major; q->major = major;
...@@ -77,7 +77,7 @@ static void __init free_hash(void) ...@@ -77,7 +77,7 @@ static void __init free_hash(void)
while (*p) { while (*p) {
q = *p; q = *p;
*p = q->next; *p = q->next;
free(q); kfree(q);
} }
} }
} }
...@@ -445,10 +445,10 @@ static char * __init unpack_to_rootfs(char *buf, unsigned len, int check_only) ...@@ -445,10 +445,10 @@ static char * __init unpack_to_rootfs(char *buf, unsigned len, int check_only)
{ {
int written; int written;
dry_run = check_only; dry_run = check_only;
header_buf = malloc(110); header_buf = kmalloc(110, GFP_KERNEL);
symlink_buf = malloc(PATH_MAX + N_ALIGN(PATH_MAX) + 1); symlink_buf = kmalloc(PATH_MAX + N_ALIGN(PATH_MAX) + 1, GFP_KERNEL);
name_buf = malloc(N_ALIGN(PATH_MAX)); name_buf = kmalloc(N_ALIGN(PATH_MAX), GFP_KERNEL);
window = malloc(WSIZE); window = kmalloc(WSIZE, GFP_KERNEL);
if (!window || !header_buf || !symlink_buf || !name_buf) if (!window || !header_buf || !symlink_buf || !name_buf)
panic("can't allocate buffers"); panic("can't allocate buffers");
state = Start; state = Start;
...@@ -484,10 +484,10 @@ static char * __init unpack_to_rootfs(char *buf, unsigned len, int check_only) ...@@ -484,10 +484,10 @@ static char * __init unpack_to_rootfs(char *buf, unsigned len, int check_only)
buf += inptr; buf += inptr;
len -= inptr; len -= inptr;
} }
free(window); kfree(window);
free(name_buf); kfree(name_buf);
free(symlink_buf); kfree(symlink_buf);
free(header_buf); kfree(header_buf);
return message; return message;
} }
......
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