Skip to contentSkip to conversation

kbuild: fixdep: Check fstat(2) return value

PATCH In review Tom Rini 1 participant 2 messages May 13, 2016 – May 23, 2016 Kbuild

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/1 kbuild: fixdep: Check fstat(2) return value

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 ]

---
 scripts/basic/fixdep.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
scripts/basic/fixdep.c +5 -1
index e8e8c77..9bd0de2 100644
@@ -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;
Signature · 1 line
1.9.1
author
#1 lore raw
Quoted 8 lines · Tom Rini

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 ]

Applied to u-boot/master, 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/20160523/ba062851/attachment.sig>