From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 51B77A0524; Fri, 19 Feb 2021 18:54:51 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BF714160964; Fri, 19 Feb 2021 18:54:50 +0100 (CET) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mails.dpdk.org (Postfix) with ESMTP id 5F9CD160962; Fri, 19 Feb 2021 18:54:48 +0100 (CET) IronPort-SDR: OUAUy+Mva1bu1CKYPwrVfPauYIevJ8i6eXYpvLU+t5OKLXU+Gw9D3sZs54wOMaqX+ILf1a/SWd D1wsKkTjkz8w== X-IronPort-AV: E=McAfee;i="6000,8403,9900"; a="181361790" X-IronPort-AV: E=Sophos;i="5.81,189,1610438400"; d="scan'208";a="181361790" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2021 09:54:47 -0800 IronPort-SDR: S3pULs6VUlrLre911zryJRb9G7h0FYrC/irkBI52jlWq3Y0rl5Jfd9I5veE0XFl3NkM5omQKzl OBYXnteTJSlQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,189,1610438400"; d="scan'208";a="581763990" Received: from silpixa00399498.ir.intel.com (HELO silpixa00399498.ger.corp.intel.com) ([10.237.222.93]) by orsmga005.jf.intel.com with ESMTP; 19 Feb 2021 09:54:46 -0800 From: Anatoly Burakov To: dev@dpdk.org Cc: stable@dpdk.org Date: Fri, 19 Feb 2021 17:54:45 +0000 Message-Id: X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] fbarray: fix uninitialized variable usage X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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 file truncation fails, the log message attempts to print a path of file we failed to truncate, but this path was never set to anything and, what's worse, was uninitialized. Fix it by passing path from the caller. Fixes: c44d09811b40 ("eal: add shared indexed file-backed array") Cc: stable@dpdk.org Coverity ID: 366122 Signed-off-by: Anatoly Burakov --- lib/librte_eal/common/eal_common_fbarray.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/librte_eal/common/eal_common_fbarray.c b/lib/librte_eal/common/eal_common_fbarray.c index d974f3dab7..592ec58594 100644 --- a/lib/librte_eal/common/eal_common_fbarray.c +++ b/lib/librte_eal/common/eal_common_fbarray.c @@ -81,9 +81,8 @@ get_used_mask(void *data, unsigned int elt_sz, unsigned int len) } static int -resize_and_map(int fd, void *addr, size_t len) +resize_and_map(int fd, const char *path, void *addr, size_t len) { - char path[PATH_MAX]; void *map_addr; if (eal_file_truncate(fd, len)) { @@ -792,7 +791,7 @@ rte_fbarray_init(struct rte_fbarray *arr, const char *name, unsigned int len, if (eal_file_lock(fd, EAL_FLOCK_SHARED, EAL_FLOCK_RETURN)) goto fail; - if (resize_and_map(fd, data, mmap_len)) + if (resize_and_map(fd, path, data, mmap_len)) goto fail; } ma->addr = data; @@ -895,7 +894,7 @@ rte_fbarray_attach(struct rte_fbarray *arr) if (eal_file_lock(fd, EAL_FLOCK_SHARED, EAL_FLOCK_RETURN)) goto fail; - if (resize_and_map(fd, data, mmap_len)) + if (resize_and_map(fd, path, data, mmap_len)) goto fail; /* store our new memory area */ -- 2.25.1