public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Ladislav Michl <ladis@linux-mips.org>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] Re: [PATCH] !CFG_MEMTEST_SCRATCH - do not dereference NULL ptr
Date: Thu, 25 Nov 2004 12:22:23 +0100	[thread overview]
Message-ID: <20041125112223.GA4635@simek> (raw)
In-Reply-To: <20041122110723.AD1A2C1430@atlas.denx.de>

On Mon, Nov 22, 2004 at 12:07:18PM +0100, Wolfgang Denk wrote:
> There is no explanation what it does or which problem it is  supposed
> to fix.

When CFG_MEMTEST_SCRATCH is undefined alternate memory test in do_mem_mtest
(with CFG_ALT_MEMTEST defined) dereferences null pointer. It defines:
vu_long *dummy = NULL;
and later does:
*dummy  = ~val;

> There is also no CHANGELOG entry.

CHANGELOG
* Patch by Ladislav Michl, 22 November 2004
  - Fix NULL pointer dereference in alternate memory test (CFG_ALT_MEMTEST)
    when if no CFG_MEMTEST_SCRATCH area defined

Index: common/cmd_mem.c
===================================================================
RCS file: /cvsroot/u-boot/u-boot/common/cmd_mem.c,v
retrieving revision 1.19
diff -p -u -r1.19 cmd_mem.c
--- common/cmd_mem.c	10 Oct 2004 23:27:33 -0000	1.19
+++ common/cmd_mem.c	22 Nov 2004 11:21:43 -0000
@@ -646,8 +646,9 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int 
 	vu_long	num_words;
 #if defined(CFG_MEMTEST_SCRATCH)
 	vu_long *dummy = (vu_long*)CFG_MEMTEST_SCRATCH;
+#define write_dummy(val)	do { *dummy  = ~val; } while (0)
 #else
-	vu_long *dummy = NULL;
+#define write_dummy(val)	do { } while (0)
 #endif
 	int	j;
 	int iterations = 1;
@@ -723,7 +724,7 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int 
 		    val = bitpattern[j];
 		    for(; val != 0; val <<= 1) {
 			*addr  = val;
-			*dummy  = ~val; /* clear the test data off of the bus */
+			write_dummy(~val); /* clear the test data off of the bus */
 			readback = *addr;
 			if(readback != val) {
 			     printf ("FAILURE (data line): "
@@ -731,11 +732,11 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int 
 					  val, readback);
 			}
 			*addr  = ~val;
-			*dummy  = val;
+			write_dummy(val);
 			readback = *addr;
 			if(readback != ~val) {
 			    printf ("FAILURE (data line): "
-				"Is %08lx, should be %08lx\n",
+				"is %08lx, should be %08lx\n",
 					readback, ~val);
 			}
 		    }

  reply	other threads:[~2004-11-25 11:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20041122100122.GA5418@simek>
2004-11-22 11:07 ` [U-Boot-Users] Re: [PATCH] !CFG_MEMTEST_SCRATCH - do not dereference NULL ptr Wolfgang Denk
2004-11-25 11:22   ` Ladislav Michl [this message]
2004-11-29  9:20     ` Ladislav Michl
2004-11-29  9:36       ` Wolfgang Denk
2004-11-29 14:15 VanBaren, Gerald
2004-11-29 15:35 ` Ladislav Michl
2005-05-30 12:44   ` Wolfgang Denk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20041125112223.GA4635@simek \
    --to=ladis@linux-mips.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox