Skip to content

Commit

Permalink
directly use kmalloc() and kfree() in init/initramfs.c
Browse files Browse the repository at this point in the history
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: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Matt Mackall <mpm@selenic.com>
Cc: Jan Engelhardt <jengelh@computergmbh.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Thomas Petazzoni authored and Linus Torvalds committed Apr 29, 2008
1 parent 5f97a5a commit 3265e66
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions init/initramfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ static char __init *find_link(int major, int minor, int ino,
continue;
return (*p)->name;
}
q = (struct hash *)malloc(sizeof(struct hash));
q = kmalloc(sizeof(struct hash), GFP_KERNEL);
if (!q)
panic("can't allocate link hash entry");
q->major = major;
Expand All @@ -77,7 +77,7 @@ static void __init free_hash(void)
while (*p) {
q = *p;
*p = q->next;
free(q);
kfree(q);
}
}
}
Expand Down Expand Up @@ -445,10 +445,10 @@ static char * __init unpack_to_rootfs(char *buf, unsigned len, int check_only)
{
int written;
dry_run = check_only;
header_buf = malloc(110);
symlink_buf = malloc(PATH_MAX + N_ALIGN(PATH_MAX) + 1);
name_buf = malloc(N_ALIGN(PATH_MAX));
window = malloc(WSIZE);
header_buf = kmalloc(110, GFP_KERNEL);
symlink_buf = kmalloc(PATH_MAX + N_ALIGN(PATH_MAX) + 1, GFP_KERNEL);
name_buf = kmalloc(N_ALIGN(PATH_MAX), GFP_KERNEL);
window = kmalloc(WSIZE, GFP_KERNEL);
if (!window || !header_buf || !symlink_buf || !name_buf)
panic("can't allocate buffers");
state = Start;
Expand Down Expand Up @@ -484,10 +484,10 @@ static char * __init unpack_to_rootfs(char *buf, unsigned len, int check_only)
buf += inptr;
len -= inptr;
}
free(window);
free(name_buf);
free(symlink_buf);
free(header_buf);
kfree(window);
kfree(name_buf);
kfree(symlink_buf);
kfree(header_buf);
return message;
}

Expand Down

0 comments on commit 3265e66

Please sign in to comment.