Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] Fix potential NULL pointer deref in gen_init_cpio

Fix potential NULL pointer deref in gen_init_cpio.c spotted by coverity
checker. This fixes coverity bug #86

Without this patch we risk dereferencing a NULL `type' in the
"if ('\n' == *type) {" line.

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Jesper Juhl and committed by
Linus Torvalds
aa1e816f 9dfb563b

+3 -1
+3 -1
usr/gen_init_cpio.c
··· 471 471 "ERROR: incorrect format, could not locate file type line %d: '%s'\n", 472 472 line_nr, line); 473 473 ec = -1; 474 + break; 474 475 } 475 476 476 477 if ('\n' == *type) { ··· 507 506 line_nr, line); 508 507 } 509 508 } 510 - cpio_trailer(); 509 + if (ec == 0) 510 + cpio_trailer(); 511 511 512 512 exit(ec); 513 513 }