Skip to contentSkip to conversation

libfdt: Initialize the stack variable

PATCH New tien.fong.chee at intel.com 3 participants 4 messages Aug 24, 2017 – Aug 30, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libfdt: Initialize the stack variable

From: Tien Fong Chee <[email protected]>

Report Coverity log:
The code uses a variable that has not
been initialized, leading to unpredictable
or unintended results.

---
 lib/libfdt/fdt_wip.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
lib/libfdt/fdt_wip.c +1 -1
index 45fb964..01adad0 100644
@@ -115,7 +115,7 @@ int fdt_find_regions(const void *fdt, char * const inc[], int inc_count,
 		     struct fdt_region region[], int max_regions,
 		     char *path, int path_len, int add_string_tab)
 {
-	int stack[FDT_MAX_DEPTH];
+	int stack[FDT_MAX_DEPTH] = { 0 };
 	char *end;
 	int nextoffset = 0;
 	uint32_t tag;
Signature · 1 line
1.7.7.4
#1 lore raw

PATCH 1/1 libfdt: Initialize the stack variable

Quoted 17 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Report Coverity log:
The code uses a variable that has not
been initialized, leading to unpredictable
or unintended results.

---
 lib/libfdt/fdt_wip.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
lib/libfdt/fdt_wip.c +0 -0
index 45fb964..01adad0 100644

lib/libfdt/fdt_wip.c int fdt_find_regions(const void *fdt, char * const inc[], int inc_count, · line 121

Quoted 8 lines
lib/libfdt/fdt_wip.c +1 -1
@@ -115,7 +115,7 @@ int fdt_find_regions(const void *fdt, char * const inc[], int inc_count,
 		     struct fdt_region region[], int max_regions,
 		     char *path, int path_len, int add_string_tab)
 {
-	int stack[FDT_MAX_DEPTH];
+	int stack[FDT_MAX_DEPTH] = { 0 };
 	char *end;
 	int nextoffset = 0;
 	uint32_t tag;

Since this comes from libfdt, have you checked there as well? And in general, we use a Reported-by: Coverity (CID: xxxx) for issues. BTW, if you would like access to the community version of Coverity, please sign up at https://scan.coverity.com/projects/das-u-boot?tab=overview thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170824/f831b64e/attachment.sig>
#2 lore raw

PATCH 1/1 libfdt: Initialize the stack variable

Quoted 29 lines · Tom Rini
Quoted 26 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Report Coverity log:
The code uses a variable that has not
been initialized, leading to unpredictable
or unintended results.

---
 lib/libfdt/fdt_wip.c |    2 +-

 1 files changed, 1 insertions(+), 1 deletions(-)
lib/libfdt/fdt_wip.c +1 -1
index 45fb964..01adad0 100644
@@ -115,7 +115,7 @@ int fdt_find_regions(const void *fdt, char *
 const inc[], int inc_count,
  		     struct fdt_region region[], int max_regions,
  		     char *path, int path_len, int add_string_tab)
  {
-	int stack[FDT_MAX_DEPTH];
+	int stack[FDT_MAX_DEPTH] = { 0 };
  	char *end;
  	int nextoffset = 0;
Quoted 8 lines
Quoted 1 line

  uint32_t tag;

Since this comes from libfdt, have you checked there as well?  And in general, we use a Reported-by: Coverity (CID: xxxx) for issues.  BTW, if
you would like access to the community version of Coverity, please sign
up at https://scan.coverity.com/projects/das-u-boot?tab=overview
thanks!

I think we didn't check all of them, our coverity only check against our socfpga use cases. But, i failed to "Add me to project", i can't view all the defects. Does community coverity found the similar warning as this patch?

Thanks.

Quoted 1 line
#3 lore raw

PATCH 1/1 libfdt: Initialize the stack variable

In reply to Tom Rini
Quoted 29 lines · Tom Rini
Quoted 26 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Report Coverity log:
The code uses a variable that has not
been initialized, leading to unpredictable
or unintended results.

---
 lib/libfdt/fdt_wip.c |    2 +-

 1 files changed, 1 insertions(+), 1 deletions(-)
lib/libfdt/fdt_wip.c +1 -1
index 45fb964..01adad0 100644
@@ -115,7 +115,7 @@ int fdt_find_regions(const void *fdt, char *
 const inc[], int inc_count,
  		     struct fdt_region region[], int max_regions,
  		     char *path, int path_len, int add_string_tab)
  {
-	int stack[FDT_MAX_DEPTH];
+	int stack[FDT_MAX_DEPTH] = { 0 };
  	char *end;
  	int nextoffset = 0;
Quoted 9 lines
Quoted 1 line

  uint32_t tag;

Since this comes from libfdt, have you checked there as well?  And in general, we use a Reported-by: Coverity (CID: xxxx) for issues.  BTW, if
you would like access to the community version of Coverity, please sign
up at https://scan.coverity.com/projects/das-u-boot?tab=overview
thanks!

Okay, i can add myself to Das U-boot coverity project finally. This warning is reported by CID: 60519. I will send out another patch with Reported-by in commit messages.
Thanks.