From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, HK_RANDOM_FROM,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6B06C0650F for ; Mon, 5 Aug 2019 05:31:04 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id 8BB0320B1F for ; Mon, 5 Aug 2019 05:31:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8BB0320B1F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B22EB1BE47; Mon, 5 Aug 2019 07:31:03 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 0C4431BE45; Mon, 5 Aug 2019 07:31:01 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Aug 2019 22:31:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,348,1559545200"; d="scan'208";a="257611367" Received: from dpdk-xiaoyunl.sh.intel.com ([10.67.110.193]) by orsmga001.jf.intel.com with ESMTP; 04 Aug 2019 22:30:59 -0700 From: Xiaoyun Li To: jingjing.wu@intel.com Cc: dev@dpdk.org, Xiaoyun Li , stable@dpdk.org Date: Mon, 5 Aug 2019 13:03:13 +0800 Message-Id: <20190805050313.28719-1-xiaoyun.li@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] examples/ntb: fix error handling X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This patch adds return value checking for fseek function to fix error handling issue found by coverity scan. Coverity issue: 344996 Fixes: c5eebf85badc ("examples/ntb: add example for NTB") Cc: stable@dpdk.org Signed-off-by: Xiaoyun Li --- examples/ntb/ntb_fwd.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/examples/ntb/ntb_fwd.c b/examples/ntb/ntb_fwd.c index c169f01a3..671b13f50 100644 --- a/examples/ntb/ntb_fwd.c +++ b/examples/ntb/ntb_fwd.c @@ -107,6 +107,7 @@ cmd_sendfile_parsed(void *parsed_result, uint8_t *buff; uint32_t val; FILE *file; + int status; if (!rte_rawdevs[dev_id].started) { printf("Device needs to be up first. Try later.\n"); @@ -125,9 +126,17 @@ cmd_sendfile_parsed(void *parsed_result, return; } - fseek(file, 0, SEEK_END); + status = fseek(file, 0, SEEK_END); + if (status) { + printf("Fail to get file size.\n"); + return; + } size = ftell(file); - fseek(file, 0, SEEK_SET); + status = fseek(file, 0, SEEK_SET); + if (status) { + printf("Fail to get file size.\n"); + return; + } /** * No FIFO now. Only test memory. Limit sending file -- 2.17.1