Patchwork Protect against NULL pointer deref in phyp-dump code.

login
register
mail settings
Submitter Tony Breeds
Date Dec. 16, 2008, 4:17 a.m.
Message ID <20081216041748.GB14890@ozlabs.org>
Download mbox | patch
Permalink /patch/14155/
State Accepted
Commit 7a2eab0d4e656341cc0f6481d722d410f0414f0b
Delegated to: Paul Mackerras
Headers show

Comments

Tony Breeds - Dec. 16, 2008, 4:17 a.m.
print_dump_header() will be called at least once with a NULL pointer in
a normal boot sequence.  if DEBUG is defined then we will get a deref,
add a quick fix to exit early in the NULL pointer case.

Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>
---
 arch/powerpc/platforms/pseries/phyp_dump.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
Manish Ahuja - Dec. 16, 2008, 10:18 p.m.
Acked-by: Manish Ahuja <mahujam@gmail.com>


Tony Breeds wrote:
> print_dump_header() will be called at least once with a NULL pointer in
> a normal boot sequence.  if DEBUG is defined then we will get a deref,
> add a quick fix to exit early in the NULL pointer case.
> 
> Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>
> ---
>  arch/powerpc/platforms/pseries/phyp_dump.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/pseries/phyp_dump.c b/arch/powerpc/platforms/pseries/phyp_dump.c
> index edbc012..16e659a 100644
> --- a/arch/powerpc/platforms/pseries/phyp_dump.c
> +++ b/arch/powerpc/platforms/pseries/phyp_dump.c
> @@ -130,6 +130,9 @@ static unsigned long init_dump_header(struct phyp_dump_header *ph)
>  static void print_dump_header(const struct phyp_dump_header *ph)
>  {
>  #ifdef DEBUG
> +	if (ph == NULL)
> +		return;
> +
>  	printk(KERN_INFO "dump header:\n");
>  	/* setup some ph->sections required */
>  	printk(KERN_INFO "version = %d\n", ph->version);

Patch

diff --git a/arch/powerpc/platforms/pseries/phyp_dump.c b/arch/powerpc/platforms/pseries/phyp_dump.c
index edbc012..16e659a 100644
--- a/arch/powerpc/platforms/pseries/phyp_dump.c
+++ b/arch/powerpc/platforms/pseries/phyp_dump.c
@@ -130,6 +130,9 @@  static unsigned long init_dump_header(struct phyp_dump_header *ph)
 static void print_dump_header(const struct phyp_dump_header *ph)
 {
 #ifdef DEBUG
+	if (ph == NULL)
+		return;
+
 	printk(KERN_INFO "dump header:\n");
 	/* setup some ph->sections required */
 	printk(KERN_INFO "version = %d\n", ph->version);