Commit 3265e66b1825942c6e0fc457986cdf941a5f7d37

Authored by Thomas Petazzoni
Committed by Linus Torvalds
1 parent 5f97a5a879

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: 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>

Showing 1 changed file with 10 additions and 10 deletions Side-by-side Diff

... ... @@ -57,7 +57,7 @@
57 57 continue;
58 58 return (*p)->name;
59 59 }
60   - q = (struct hash *)malloc(sizeof(struct hash));
  60 + q = kmalloc(sizeof(struct hash), GFP_KERNEL);
61 61 if (!q)
62 62 panic("can't allocate link hash entry");
63 63 q->major = major;
... ... @@ -77,7 +77,7 @@
77 77 while (*p) {
78 78 q = *p;
79 79 *p = q->next;
80   - free(q);
  80 + kfree(q);
81 81 }
82 82 }
83 83 }
... ... @@ -445,10 +445,10 @@
445 445 {
446 446 int written;
447 447 dry_run = check_only;
448   - header_buf = malloc(110);
449   - symlink_buf = malloc(PATH_MAX + N_ALIGN(PATH_MAX) + 1);
450   - name_buf = malloc(N_ALIGN(PATH_MAX));
451   - window = malloc(WSIZE);
  448 + header_buf = kmalloc(110, GFP_KERNEL);
  449 + symlink_buf = kmalloc(PATH_MAX + N_ALIGN(PATH_MAX) + 1, GFP_KERNEL);
  450 + name_buf = kmalloc(N_ALIGN(PATH_MAX), GFP_KERNEL);
  451 + window = kmalloc(WSIZE, GFP_KERNEL);
452 452 if (!window || !header_buf || !symlink_buf || !name_buf)
453 453 panic("can't allocate buffers");
454 454 state = Start;
... ... @@ -484,10 +484,10 @@
484 484 buf += inptr;
485 485 len -= inptr;
486 486 }
487   - free(window);
488   - free(name_buf);
489   - free(symlink_buf);
490   - free(header_buf);
  487 + kfree(window);
  488 + kfree(name_buf);
  489 + kfree(symlink_buf);
  490 + kfree(header_buf);
491 491 return message;
492 492 }
493 493