* [PATCH v1 0/5] random fixes
@ 2018-11-10 7:59 Oleksij Rempel
2018-11-10 7:59 ` [PATCH v1 1/5] commands: keystore: init s_len Oleksij Rempel
` (4 more replies)
0 siblings, 5 replies; 9+ messages in thread
From: Oleksij Rempel @ 2018-11-10 7:59 UTC (permalink / raw)
To: barebox; +Cc: Oleksij Rempel
Some random fixes for issues found by https://app.codacy.com
Oleksij Rempel (5):
commands: keystore: init s_len
ddr_spd: remove unused array
video/ssd1307fb: fix potential memory leak on error
clk: imx: cpu: avoid use after free on error
of: partition: set ret for error cases
commands/keystore.c | 2 +-
common/ddr_spd.c | 2 --
drivers/clk/imx/clk-cpu.c | 4 +++-
drivers/of/partition.c | 4 ++--
drivers/video/ssd1307fb.c | 8 ++++++--
5 files changed, 12 insertions(+), 8 deletions(-)
--
2.17.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v1 1/5] commands: keystore: init s_len
2018-11-10 7:59 [PATCH v1 0/5] random fixes Oleksij Rempel
@ 2018-11-10 7:59 ` Oleksij Rempel
2018-11-12 7:34 ` Sascha Hauer
2018-11-10 7:59 ` [PATCH v1 2/5] ddr_spd: remove unused array Oleksij Rempel
` (3 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Oleksij Rempel @ 2018-11-10 7:59 UTC (permalink / raw)
To: barebox; +Cc: Oleksij Rempel
if read_file_2 will fail, s_len will stay uninitialized.
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
---
commands/keystore.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/commands/keystore.c b/commands/keystore.c
index 52c4be263..50a6c8494 100644
--- a/commands/keystore.c
+++ b/commands/keystore.c
@@ -15,7 +15,7 @@ static int do_keystore(int argc, char *argv[])
const char *file = NULL;
char *secret_str = NULL;
void *secret;
- int s_len;
+ int s_len = 0;
while ((opt = getopt(argc, argv, "rs:f:")) > 0) {
switch (opt) {
--
2.17.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v1 2/5] ddr_spd: remove unused array
2018-11-10 7:59 [PATCH v1 0/5] random fixes Oleksij Rempel
2018-11-10 7:59 ` [PATCH v1 1/5] commands: keystore: init s_len Oleksij Rempel
@ 2018-11-10 7:59 ` Oleksij Rempel
2018-11-10 7:59 ` [PATCH v1 3/5] video/ssd1307fb: fix potential memory leak on error Oleksij Rempel
` (2 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Oleksij Rempel @ 2018-11-10 7:59 UTC (permalink / raw)
To: barebox; +Cc: Oleksij Rempel
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
---
common/ddr_spd.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/common/ddr_spd.c b/common/ddr_spd.c
index ec343ef5a..7e2945ed9 100644
--- a/common/ddr_spd.c
+++ b/common/ddr_spd.c
@@ -166,7 +166,6 @@ static int ddr2_sdram_ctime(uint8_t byte)
void ddr_spd_print(uint8_t *record)
{
int highestCAS = 0;
- int cas[256];
int i, i_i, k, x, y;
int ddrclk, tbits, pcclk;
int trcd, trp, tras;
@@ -199,7 +198,6 @@ void ddr_spd_print(uint8_t *record)
for (i_i = 2; i_i < 7; i_i++) {
if (s->cas_lat & 1 << i_i) {
highestCAS = i_i;
- cas[highestCAS]++;
}
}
--
2.17.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v1 3/5] video/ssd1307fb: fix potential memory leak on error
2018-11-10 7:59 [PATCH v1 0/5] random fixes Oleksij Rempel
2018-11-10 7:59 ` [PATCH v1 1/5] commands: keystore: init s_len Oleksij Rempel
2018-11-10 7:59 ` [PATCH v1 2/5] ddr_spd: remove unused array Oleksij Rempel
@ 2018-11-10 7:59 ` Oleksij Rempel
2018-11-16 7:52 ` Sascha Hauer
2018-11-10 7:59 ` [PATCH v1 4/5] clk: imx: cpu: avoid use after free " Oleksij Rempel
2018-11-10 7:59 ` [PATCH v1 5/5] of: partition: set ret for error cases Oleksij Rempel
4 siblings, 1 reply; 9+ messages in thread
From: Oleksij Rempel @ 2018-11-10 7:59 UTC (permalink / raw)
To: barebox; +Cc: Oleksij Rempel
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
---
drivers/video/ssd1307fb.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/video/ssd1307fb.c b/drivers/video/ssd1307fb.c
index d68f0c505..1fd1a3cfb 100644
--- a/drivers/video/ssd1307fb.c
+++ b/drivers/video/ssd1307fb.c
@@ -548,8 +548,11 @@ static int ssd1307fb_probe(struct device_d *dev)
/* clear display */
array = ssd1307fb_alloc_array(par->width * par->height / 8,
SSD1307FB_DATA);
- if (!array)
- return -ENOMEM;
+ if (!array) {
+ dev_err(&client->dev, "Couldn't not allocate an array\n");
+ ret = -ENOMEM;
+ goto panel_init_error;
+ }
for (i = 0; i < (par->height / 8); i++) {
for (j = 0; j < par->width; j++) {
@@ -569,6 +572,7 @@ static int ssd1307fb_probe(struct device_d *dev)
panel_init_error:
reset_oled_error:
+ free(vmem);
fb_alloc_error:
regulator_disable(par->vbat);
free(info);
--
2.17.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v1 4/5] clk: imx: cpu: avoid use after free on error
2018-11-10 7:59 [PATCH v1 0/5] random fixes Oleksij Rempel
` (2 preceding siblings ...)
2018-11-10 7:59 ` [PATCH v1 3/5] video/ssd1307fb: fix potential memory leak on error Oleksij Rempel
@ 2018-11-10 7:59 ` Oleksij Rempel
2018-11-12 7:36 ` Sascha Hauer
2018-11-10 7:59 ` [PATCH v1 5/5] of: partition: set ret for error cases Oleksij Rempel
4 siblings, 1 reply; 9+ messages in thread
From: Oleksij Rempel @ 2018-11-10 7:59 UTC (permalink / raw)
To: barebox; +Cc: Oleksij Rempel
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
---
drivers/clk/imx/clk-cpu.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/imx/clk-cpu.c b/drivers/clk/imx/clk-cpu.c
index 5ac0ed178..f9db36018 100644
--- a/drivers/clk/imx/clk-cpu.c
+++ b/drivers/clk/imx/clk-cpu.c
@@ -111,8 +111,10 @@ struct clk *imx_clk_cpu(const char *name, const char *parent_name,
cpu->clk.num_parents = 1;
ret = clk_register(&cpu->clk);
- if (ret)
+ if (ret) {
free(cpu);
+ return 0;
+ }
return &cpu->clk;
}
--
2.17.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v1 5/5] of: partition: set ret for error cases
2018-11-10 7:59 [PATCH v1 0/5] random fixes Oleksij Rempel
` (3 preceding siblings ...)
2018-11-10 7:59 ` [PATCH v1 4/5] clk: imx: cpu: avoid use after free " Oleksij Rempel
@ 2018-11-10 7:59 ` Oleksij Rempel
4 siblings, 0 replies; 9+ messages in thread
From: Oleksij Rempel @ 2018-11-10 7:59 UTC (permalink / raw)
To: barebox; +Cc: Oleksij Rempel
looks like it was forgotten.
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
---
drivers/of/partition.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/of/partition.c b/drivers/of/partition.c
index aa6e601b7..2848b9636 100644
--- a/drivers/of/partition.c
+++ b/drivers/of/partition.c
@@ -186,11 +186,11 @@ static int of_partition_fixup(struct device_node *root, void *ctx)
return ret;
}
- of_property_write_u32(partnode, "#size-cells", n_cells);
+ ret = of_property_write_u32(partnode, "#size-cells", n_cells);
if (ret)
return ret;
- of_property_write_u32(partnode, "#address-cells", n_cells);
+ ret = of_property_write_u32(partnode, "#address-cells", n_cells);
if (ret)
return ret;
--
2.17.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1 1/5] commands: keystore: init s_len
2018-11-10 7:59 ` [PATCH v1 1/5] commands: keystore: init s_len Oleksij Rempel
@ 2018-11-12 7:34 ` Sascha Hauer
0 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2018-11-12 7:34 UTC (permalink / raw)
To: Oleksij Rempel; +Cc: barebox
On Sat, Nov 10, 2018 at 08:59:50AM +0100, Oleksij Rempel wrote:
> if read_file_2 will fail, s_len will stay uninitialized.
>
> Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
> ---
> commands/keystore.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/commands/keystore.c b/commands/keystore.c
> index 52c4be263..50a6c8494 100644
> --- a/commands/keystore.c
> +++ b/commands/keystore.c
> @@ -15,7 +15,7 @@ static int do_keystore(int argc, char *argv[])
> const char *file = NULL;
> char *secret_str = NULL;
> void *secret;
> - int s_len;
> + int s_len = 0;
if read_file_2 fails then s_len is also not used.
Sascha
--
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] 9+ messages in thread
* Re: [PATCH v1 4/5] clk: imx: cpu: avoid use after free on error
2018-11-10 7:59 ` [PATCH v1 4/5] clk: imx: cpu: avoid use after free " Oleksij Rempel
@ 2018-11-12 7:36 ` Sascha Hauer
0 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2018-11-12 7:36 UTC (permalink / raw)
To: Oleksij Rempel; +Cc: barebox
On Sat, Nov 10, 2018 at 08:59:53AM +0100, Oleksij Rempel wrote:
> Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
> ---
> drivers/clk/imx/clk-cpu.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/clk/imx/clk-cpu.c b/drivers/clk/imx/clk-cpu.c
> index 5ac0ed178..f9db36018 100644
> --- a/drivers/clk/imx/clk-cpu.c
> +++ b/drivers/clk/imx/clk-cpu.c
> @@ -111,8 +111,10 @@ struct clk *imx_clk_cpu(const char *name, const char *parent_name,
> cpu->clk.num_parents = 1;
>
> ret = clk_register(&cpu->clk);
> - if (ret)
> + if (ret) {
> free(cpu);
> + return 0;
Should be return NULL.
Sascha
--
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] 9+ messages in thread
* Re: [PATCH v1 3/5] video/ssd1307fb: fix potential memory leak on error
2018-11-10 7:59 ` [PATCH v1 3/5] video/ssd1307fb: fix potential memory leak on error Oleksij Rempel
@ 2018-11-16 7:52 ` Sascha Hauer
0 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2018-11-16 7:52 UTC (permalink / raw)
To: Oleksij Rempel; +Cc: barebox
On Sat, Nov 10, 2018 at 08:59:52AM +0100, Oleksij Rempel wrote:
> Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
> ---
> drivers/video/ssd1307fb.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/video/ssd1307fb.c b/drivers/video/ssd1307fb.c
> index d68f0c505..1fd1a3cfb 100644
> --- a/drivers/video/ssd1307fb.c
> +++ b/drivers/video/ssd1307fb.c
> @@ -548,8 +548,11 @@ static int ssd1307fb_probe(struct device_d *dev)
> /* clear display */
> array = ssd1307fb_alloc_array(par->width * par->height / 8,
> SSD1307FB_DATA);
> - if (!array)
> - return -ENOMEM;
> + if (!array) {
> + dev_err(&client->dev, "Couldn't not allocate an array\n");
Please do not add messages in allocation failure pathes. When we get out
of memory it's not really interesting where it happened, at least not
when it's not the culprit itself. It would rather be interesting who ate
all your memory before.
Sascha
--
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] 9+ messages in thread
end of thread, other threads:[~2018-11-16 7:52 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-10 7:59 [PATCH v1 0/5] random fixes Oleksij Rempel
2018-11-10 7:59 ` [PATCH v1 1/5] commands: keystore: init s_len Oleksij Rempel
2018-11-12 7:34 ` Sascha Hauer
2018-11-10 7:59 ` [PATCH v1 2/5] ddr_spd: remove unused array Oleksij Rempel
2018-11-10 7:59 ` [PATCH v1 3/5] video/ssd1307fb: fix potential memory leak on error Oleksij Rempel
2018-11-16 7:52 ` Sascha Hauer
2018-11-10 7:59 ` [PATCH v1 4/5] clk: imx: cpu: avoid use after free " Oleksij Rempel
2018-11-12 7:36 ` Sascha Hauer
2018-11-10 7:59 ` [PATCH v1 5/5] of: partition: set ret for error cases Oleksij Rempel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox