summaryrefslogtreecommitdiffstats
path: root/common/console.c
diff options
context:
space:
mode:
authorAlexander Shiyan <shc_work@mail.ru>2013-07-07 16:27:17 +0400
committerSascha Hauer <s.hauer@pengutronix.de>2013-07-09 08:45:42 +0200
commit4ccf45db0a5f27b998a5dc7560bfb7a228bf5e96 (patch)
tree8c46b880d9ffed049667b1d34320c3d35bdfda8a /common/console.c
parentb90bceb6a90a1f95162527e239b332ee596bd057 (diff)
downloadbarebox-4ccf45db0a5f27b998a5dc7560bfb7a228bf5e96.tar.gz
barebox-4ccf45db0a5f27b998a5dc7560bfb7a228bf5e96.tar.xz
common: console: Fix possible null pointer dereference
doing a 'cs0.active=' on the command line crashed barebox. Fix this by not dereferencing val when it's NULL. Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/console.c')
-rw-r--r--common/console.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/common/console.c b/common/console.c
index a0a06f6300..8a4b224740 100644
--- a/common/console.c
+++ b/common/console.c
@@ -62,22 +62,21 @@ static int console_std_set(struct device_d *dev, struct param_d *param,
char active[4];
unsigned int flag = 0, i = 0;
- if (!val)
- dev_param_set_generic(dev, param, NULL);
-
- if (strchr(val, 'i') && cdev->f_caps & CONSOLE_STDIN) {
- active[i++] = 'i';
- flag |= CONSOLE_STDIN;
- }
+ if (val) {
+ if (strchr(val, 'i') && cdev->f_caps & CONSOLE_STDIN) {
+ active[i++] = 'i';
+ flag |= CONSOLE_STDIN;
+ }
- if (strchr(val, 'o') && cdev->f_caps & CONSOLE_STDOUT) {
- active[i++] = 'o';
- flag |= CONSOLE_STDOUT;
- }
+ if (strchr(val, 'o') && cdev->f_caps & CONSOLE_STDOUT) {
+ active[i++] = 'o';
+ flag |= CONSOLE_STDOUT;
+ }
- if (strchr(val, 'e') && cdev->f_caps & CONSOLE_STDERR) {
- active[i++] = 'e';
- flag |= CONSOLE_STDERR;
+ if (strchr(val, 'e') && cdev->f_caps & CONSOLE_STDERR) {
+ active[i++] = 'e';
+ flag |= CONSOLE_STDERR;
+ }
}
active[i] = 0;