From patchwork Tue May 17 07:57:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 622949 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3r88nJ24Mzz9sBG; Tue, 17 May 2016 17:57:24 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1b2ZsX-0008G5-Q7; Tue, 17 May 2016 07:57:21 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1b2ZsS-0008Fy-HV for fwts-devel@lists.ubuntu.com; Tue, 17 May 2016 07:57:16 +0000 Received: from cpc86913-craw7-2-0-cust134.16-3.cable.virginm.net ([92.239.46.135] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1b2ZsS-0003DL-6B; Tue, 17 May 2016 07:57:16 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH] fwts: lib: clean up static analysis warnings Date: Tue, 17 May 2016 08:57:14 +0100 Message-Id: <1463471834-29067-1-git-send-email-colin.king@canonical.com> X-Mailer: git-send-email 2.8.1 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: fwts-devel-bounces@lists.ubuntu.com From: Colin Ian King Although this is not possible, I'd like to clean up a warning from static analysis just for the sake ensuring we never do a write to a null pointer to the buffer. CID 1354842: Null pointer dereferences (FORWARD_NULL) Passing null pointer "in_buf" to "write", which dereferences it. Signed-off-by: Colin Ian King Acked-by: Alex Hung Acked-by: Ivan Hu --- src/lib/src/fwts_pipeio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/src/fwts_pipeio.c b/src/lib/src/fwts_pipeio.c index 859e63e..b501f7b 100644 --- a/src/lib/src/fwts_pipeio.c +++ b/src/lib/src/fwts_pipeio.c @@ -206,7 +206,7 @@ int fwts_pipe_readwrite( *(ptr+out_size) = 0; } - if (pollfds[1].revents) { + if ((in_fd > 0) && in_buf && pollfds[1].revents) { n = write(in_fd, in_buf, in_size); if (n < 0) {