* [PATCH 1/3] blackfin: Remove unneeded assignment @ 2013-07-07 12:27 Alexander Shiyan 2013-07-07 12:27 ` [PATCH 2/3] commands: nandtest: Fix incorrect size for memset in do_nandtest Alexander Shiyan 2013-07-07 12:27 ` [PATCH 3/3] common: console: Fix possible null pointer dereference Alexander Shiyan 0 siblings, 2 replies; 4+ messages in thread From: Alexander Shiyan @ 2013-07-07 12:27 UTC (permalink / raw) To: barebox Assignment of function parameter has no effect outside the function. Signed-off-by: Alexander Shiyan <shc_work@mail.ru> --- arch/blackfin/lib/bf533_string.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/blackfin/lib/bf533_string.c b/arch/blackfin/lib/bf533_string.c index ff9410f..860ee92 100644 --- a/arch/blackfin/lib/bf533_string.c +++ b/arch/blackfin/lib/bf533_string.c @@ -176,6 +176,6 @@ void *dma_memcpy(void * dest,const void *src,size_t count) *pMDMA_D0_IRQ_STATUS |= (DMA_DONE | DMA_ERR); dest += count; - src += count; + return dest; } -- 1.8.1.5 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/3] commands: nandtest: Fix incorrect size for memset in do_nandtest 2013-07-07 12:27 [PATCH 1/3] blackfin: Remove unneeded assignment Alexander Shiyan @ 2013-07-07 12:27 ` Alexander Shiyan 2013-07-07 12:27 ` [PATCH 3/3] common: console: Fix possible null pointer dereference Alexander Shiyan 1 sibling, 0 replies; 4+ messages in thread From: Alexander Shiyan @ 2013-07-07 12:27 UTC (permalink / raw) To: barebox Signed-off-by: Alexander Shiyan <shc_work@mail.ru> --- commands/nandtest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/nandtest.c b/commands/nandtest.c index ba15ecf..f6e8f99 100644 --- a/commands/nandtest.c +++ b/commands/nandtest.c @@ -181,7 +181,7 @@ static int do_nandtest(int argc, char *argv[]) markbad = 0; fd = -1; - memset(ecc_stats, 0, MAX_ECC_BITS); + memset(ecc_stats, 0, sizeof(*ecc_stats)); while ((opt = getopt(argc, argv, "ms:i:o:l:t")) > 0) { switch (opt) { -- 1.8.1.5 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 3/3] common: console: Fix possible null pointer dereference 2013-07-07 12:27 [PATCH 1/3] blackfin: Remove unneeded assignment Alexander Shiyan 2013-07-07 12:27 ` [PATCH 2/3] commands: nandtest: Fix incorrect size for memset in do_nandtest Alexander Shiyan @ 2013-07-07 12:27 ` Alexander Shiyan 2013-07-09 6:48 ` Sascha Hauer 1 sibling, 1 reply; 4+ messages in thread From: Alexander Shiyan @ 2013-07-07 12:27 UTC (permalink / raw) To: barebox Signed-off-by: Alexander Shiyan <shc_work@mail.ru> --- common/console.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/common/console.c b/common/console.c index a0a06f6..fc7b9ba 100644 --- a/common/console.c +++ b/common/console.c @@ -62,23 +62,23 @@ 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; + } + } else + dev_param_set_generic(dev, param, NULL); active[i] = 0; cdev->f_active = flag; -- 1.8.1.5 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 3/3] common: console: Fix possible null pointer dereference 2013-07-07 12:27 ` [PATCH 3/3] common: console: Fix possible null pointer dereference Alexander Shiyan @ 2013-07-09 6:48 ` Sascha Hauer 0 siblings, 0 replies; 4+ messages in thread From: Sascha Hauer @ 2013-07-09 6:48 UTC (permalink / raw) To: Alexander Shiyan; +Cc: barebox On Sun, Jul 07, 2013 at 04:27:17PM +0400, Alexander Shiyan wrote: > > Signed-off-by: Alexander Shiyan <shc_work@mail.ru> > --- > common/console.c | 30 +++++++++++++++--------------- > 1 file changed, 15 insertions(+), 15 deletions(-) > > diff --git a/common/console.c b/common/console.c > index a0a06f6..fc7b9ba 100644 > --- a/common/console.c > +++ b/common/console.c > @@ -62,23 +62,23 @@ 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; > + } > + } else > + dev_param_set_generic(dev, param, NULL); This is not necessary. dev_param_set_generic is called afterwards again. Indeed it was very easy to crash barebox by doing a 'cs0.active='. I changed the patch to the following and applied this series. Thanks Sascha 8<------------------------------------------------ From 4ccf45db0a5f27b998a5dc7560bfb7a228bf5e96 Mon Sep 17 00:00:00 2001 From: Alexander Shiyan <shc_work@mail.ru> Date: Sun, 7 Jul 2013 16:27:17 +0400 Subject: [PATCH] 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> --- common/console.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/common/console.c b/common/console.c index a0a06f6..8a4b224 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; -- 1.8.3.2 -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-07-09 6:49 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2013-07-07 12:27 [PATCH 1/3] blackfin: Remove unneeded assignment Alexander Shiyan 2013-07-07 12:27 ` [PATCH 2/3] commands: nandtest: Fix incorrect size for memset in do_nandtest Alexander Shiyan 2013-07-07 12:27 ` [PATCH 3/3] common: console: Fix possible null pointer dereference Alexander Shiyan 2013-07-09 6:48 ` Sascha Hauer
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox