From patchwork Mon Dec 7 21:26:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rini X-Patchwork-Id: 7790841 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DF7609F1C2 for ; Mon, 7 Dec 2015 21:25:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2584E20557 for ; Mon, 7 Dec 2015 21:25:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2F4D82052F for ; Mon, 7 Dec 2015 21:25:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932141AbbLGVZy (ORCPT ); Mon, 7 Dec 2015 16:25:54 -0500 Received: from mail-qg0-f52.google.com ([209.85.192.52]:36593 "EHLO mail-qg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932111AbbLGVZv (ORCPT ); Mon, 7 Dec 2015 16:25:51 -0500 Received: by qgcc31 with SMTP id c31so109010qgc.3; Mon, 07 Dec 2015 13:25:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=from:to:cc:subject:date:message-id; bh=6uLfPxlcnEcylmC9CESazfgt1H7Xgt7x/r8ZpAnJ/Ic=; b=UtowGcq0qFYneiSMtzUTImLEmErdgX6saUTOQieTrrU2LdfciolTm5hogNnnzZ5aa0 Bew0pqmIuttlrjVLlG7I9KDirT7BEwoCArfZn3zpsI+HrN8bHmjmMP1ZxqsBxr/zrsGX aj4vo1tq4RRPVEwmykb81wcRuFvQELp0LYz0AwYKYndhGa6ud9QGtydKlllBwhOTxL47 dQYsVjUgic0XPmKGdb42fwbTUht0LNIfEzlap8SwsmKS5dKsB+AFyW8SF8c7isTqHu+2 C+tqyMV8/LiEuwax9RQrVNTb5lNo+sIBNti92pvZDCmO3JJKX5VapGh6g8R4DegQHaRM 45sg== X-Received: by 10.140.159.206 with SMTP id f197mr41363678qhf.72.1449523550847; Mon, 07 Dec 2015 13:25:50 -0800 (PST) Received: from localhost.localdomain (cpe-75-180-230-22.ec.res.rr.com. [75.180.230.22]) by smtp.gmail.com with ESMTPSA id r83sm12374326qhc.8.2015.12.07.13.25.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Dec 2015 13:25:49 -0800 (PST) From: Tom Rini To: linux-kbuild@vger.kernel.org Cc: Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH] kbuild: fixdep: Check fstat(2) return value Date: Mon, 7 Dec 2015 16:26:08 -0500 Message-Id: <1449523568-31084-1-git-send-email-trini@konsulko.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Cc: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Tom Rini --- 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;