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 735D8A04C9 for ; Sun, 13 Sep 2020 21:55:13 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1E07FE07; Sun, 13 Sep 2020 21:55:13 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 513C6E07 for ; Sun, 13 Sep 2020 21:55:11 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from viacheslavo@nvidia.com) with SMTP; 13 Sep 2020 22:55:06 +0300 Received: from nvidia.com (pegasus12.mtr.labs.mlnx [10.210.17.40]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 08DJt6nx032069; Sun, 13 Sep 2020 22:55:06 +0300 From: Viacheslav Ovsiienko To: dev@dpdk.org Cc: rasland@nvidia.com, matan@nvidia.com, orika@nvidia.com, stable@dpdk.org Date: Sun, 13 Sep 2020 19:55:06 +0000 Message-Id: <1600026906-9702-1-git-send-email-viacheslavo@nvidia.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-stable] [PATCH] common/mlx5: fix PCI location address routine X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" mlx5 PMDs use the mlx5_dev_to_pci_addr() routine to convert Infiniband device name to the Bus-Device-Function location on the PCI bus. The routine returned success even in case of not found identification string. On caller side it likely caused the wrong match with the BDF of previous device resulting in wrong representor and master recognitions. Fixes: 79aa430721b1 ("common/mlx5: split common file under Linux directory") Cc: stable@dpdk.org Signed-off-by: Viacheslav Ovsiienko --- drivers/common/mlx5/linux/mlx5_common_os.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/common/mlx5/linux/mlx5_common_os.c b/drivers/common/mlx5/linux/mlx5_common_os.c index 7bb3ba6..0edd78e 100644 --- a/drivers/common/mlx5/linux/mlx5_common_os.c +++ b/drivers/common/mlx5/linux/mlx5_common_os.c @@ -39,6 +39,7 @@ { FILE *file; char line[32]; + int rc = -ENOENT; MKSTR(path, "%s/device/uevent", dev_path); file = fopen(path, "rb"); @@ -48,16 +49,19 @@ } while (fgets(line, sizeof(line), file) == line) { size_t len = strlen(line); - int ret; /* Truncate long lines. */ - if (len == (sizeof(line) - 1)) + if (len == (sizeof(line) - 1)) { while (line[(len - 1)] != '\n') { - ret = fgetc(file); + int ret = fgetc(file); + if (ret == EOF) - break; + goto exit; line[(len - 1)] = ret; } + /* No match for long lines. */ + continue; + } /* Extract information. */ if (sscanf(line, "PCI_SLOT_NAME=" @@ -66,11 +70,15 @@ &pci_addr->bus, &pci_addr->devid, &pci_addr->function) == 4) { + rc = 0; break; } } +exit: fclose(file); - return 0; + if (rc) + rte_errno = -rc; + return rc; } /** -- 1.8.3.1