public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
From: Tom Rini <trini@konsulko.com>
To: linux-kbuild@vger.kernel.org
Cc: Michal Marek <mmarek@suse.com>, linux-kernel@vger.kernel.org
Subject: [PATCH] kbuild: fixdep: Check fstat(2) return value
Date: Mon,  7 Dec 2015 16:26:08 -0500	[thread overview]
Message-ID: <1449523568-31084-1-git-send-email-trini@konsulko.com> (raw)

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.

Cc: Michal Marek <mmarek@suse.com>
Cc: linux-kbuild@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Tom Rini <trini@konsulko.com>

---
Note that I don't have a CID here was I found this in U-Boot and the
kernel hasn't yet done a build with this test being enabled.
---
 scripts/basic/fixdep.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
index c68fd61..e3d9678 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -274,7 +274,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;
-- 
1.7.9.5


             reply	other threads:[~2015-12-07 21:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-07 21:26 Tom Rini [this message]
2016-01-16 19:14 ` [PATCH] kbuild: fixdep: Check fstat(2) return value Tom Rini
     [not found] ` <CA+M6bXnTB286iFoSFUneGq=1PCJtmnR_PBrqMeM4eu-Aj1BqMA@mail.gmail.com>
2016-02-16 15:32   ` Tom Rini
2016-02-17 21:58     ` Michal Marek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1449523568-31084-1-git-send-email-trini@konsulko.com \
    --to=trini@konsulko.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mmarek@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox