From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id EC496A00E6 for ; Mon, 5 Aug 2019 07:31:03 +0200 (CEST) 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