From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH] mem md: make md -s /dev/something work again
Date: Tue, 31 Jul 2012 21:45:42 +0200 [thread overview]
Message-ID: <1343763942-5011-1-git-send-email-s.hauer@pengutronix.de> (raw)
Since
|commit d22b85a203aea20a2b2618f5f457fe96c502868d
|Author: Sascha Hauer <s.hauer@pengutronix.de>
|Date: Wed Jul 4 23:41:13 2012 +0200
|
| mem md: bail out without arguments
|
| Without arguments the 'md' command defaults to show address 0 which
| likely results in a NULL pointer exception, so only three keystrokes
| are necessary to crash barebox. Show usage instead if 'md' is invoked
| without arguments, so that it at least requires an address to be given
| to crash barebox. This increases the stability of barebox by 66%. Hurray!
barebox does not crash any longer when a plain 'md' without additional arguments
is exectuted. However, doing a 'md -s /dev/nor0' was a standard usecase which now
does not work anymore.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
commands/mem.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/commands/mem.c b/commands/mem.c
index 5322def..cc94062 100644
--- a/commands/mem.c
+++ b/commands/mem.c
@@ -170,6 +170,9 @@ static int do_mem_md(int argc, char *argv[])
char *filename = DEVMEM;
int mode = O_RWSIZE_4;
+ if (argc < 2)
+ return COMMAND_ERROR_USAGE;
+
if (mem_parse_options(argc, argv, "bwls:", &mode, &filename, NULL) < 0)
return 1;
@@ -180,8 +183,6 @@ static int do_mem_md(int argc, char *argv[])
}
if (size == ~0)
size = 0x100;
- } else {
- return COMMAND_ERROR_USAGE;
}
fd = open_and_lseek(filename, mode | O_RDONLY, start);
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
reply other threads:[~2012-07-31 19:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1343763942-5011-1-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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