diff mbox

[U-Boot] kbuild: fixdep: Check fstat(2) return value

Message ID 1463151244-7873-1-git-send-email-trini@konsulko.com
State Accepted
Commit c1420f8b2b0f3c833c024979495ab22db34a5dbe
Delegated to: Tom Rini
Headers show

Commit Message

Tom Rini May 13, 2016, 2:54 p.m. UTC
Coverity has recently added a check that will find when we don't check
the return code from fstat(2).  Copy/paste the checking logic that
print_deps() has with an appropriate re-wording of the perror() message.

[ Linux commit : 46fe94ad18aa7ce6b3dad8c035fb538942020f2b ]

Signed-off-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Michal Marek <mmarek@suse.com>
---
 scripts/basic/fixdep.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Tom Rini May 23, 2016, 10:14 p.m. UTC | #1
On Fri, May 13, 2016 at 10:54:04AM -0400, Tom Rini wrote:

> Coverity has recently added a check that will find when we don't check
> the return code from fstat(2).  Copy/paste the checking logic that
> print_deps() has with an appropriate re-wording of the perror() message.
> 
> [ Linux commit : 46fe94ad18aa7ce6b3dad8c035fb538942020f2b ]
> 
> Signed-off-by: Tom Rini <trini@konsulko.com>
> Signed-off-by: Michal Marek <mmarek@suse.com>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
index e8e8c77..9bd0de2 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -296,7 +296,11 @@  static void do_config_file(const char *filename)
 		perror(filename);
 		exit(2);
 	}
-	fstat(fd, &st);
+	if (fstat(fd, &st) < 0) {
+		fprintf(stderr, "fixdep: error fstat'ing config file: ");
+		perror(filename);
+		exit(2);
+	}
 	if (st.st_size == 0) {
 		close(fd);
 		return;