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 D4960A04C2; Mon, 25 Nov 2019 17:47:50 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BB964CF3; Mon, 25 Nov 2019 17:47:49 +0100 (CET) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 8DF5FA3 for ; Mon, 25 Nov 2019 17:47:48 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Nov 2019 08:47:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,242,1571727600"; d="scan'208";a="211080832" Received: from silpixa00399126.ir.intel.com (HELO silpixa00399126.ger.corp.intel.com) ([10.237.223.2]) by orsmga003.jf.intel.com with ESMTP; 25 Nov 2019 08:47:46 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson Date: Mon, 25 Nov 2019 16:47:41 +0000 Message-Id: <20191125164741.70488-1-bruce.richardson@intel.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] examples/ioat: fix possible null dereference 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" When searching for raw devices with the correct type, we check the driver name using strcmp, without first checking that the call to info get succeeded and assigned a value to that pointer. If the call to get the device info fails, we can treat it as if the device didn't match, and continue the loop, so the easiest fix is just to skip the strcmp if the driver_name is null. [A non-null value from a previous failed match is ok as it too causes the same behaviour of another loop iteration]. Coverity issue: 350353 Fixes: 2328542ed84e ("examples/ioat: add rawdev copy mode") Signed-off-by: Bruce Richardson --- examples/ioat/ioatfwd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/ioat/ioatfwd.c b/examples/ioat/ioatfwd.c index a0cc5c496..e9117718f 100644 --- a/examples/ioat/ioatfwd.c +++ b/examples/ioat/ioatfwd.c @@ -751,8 +751,9 @@ assign_rawdevs(void) if (rdev_id == rte_rawdev_count()) goto end; rte_rawdev_info_get(rdev_id++, &rdev_info); - } while (strcmp(rdev_info.driver_name, - IOAT_PMD_RAWDEV_NAME_STR) != 0); + } while (rdev_info.driver_name == NULL || + strcmp(rdev_info.driver_name, + IOAT_PMD_RAWDEV_NAME_STR) != 0); cfg.ports[i].ioat_ids[j] = rdev_id - 1; configure_rawdev_queue(cfg.ports[i].ioat_ids[j]); -- 2.21.0