From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by dpdk.org (Postfix) with ESMTP id 855B71B758 for ; Fri, 8 Feb 2019 04:44:20 +0100 (CET) Received: by mail-pl1-f196.google.com with SMTP id p4so1023072plq.11 for ; Thu, 07 Feb 2019 19:44:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ArJKO28hLj0K5VjH+0jBSnG6Yg4WWDwmTUVgCvjH65w=; b=OwKjsqoxzE1DjQ3i3SFtAKxWdFLhwHLLVg0gc55rpVNHfT5Llu9Ei/doTqg2PWjhq2 OUz/JlaQa06DFP2XVLo3tOwYviI6Md0BMF2xTTJHvdTVzsSaCzI+enx4CQoWAaAhmCYv VmvJqCV1pyOm25QZDEnrPR5QSqCn40nUG9EB22k/82pXtKNthu1mFZ1OnJ6+dQ0wE3// FGieIA/JvbPuPFc4OBkz6ZpyG5iliBGGJb8OR9W/M5EeXtRTt732uwduHii4gcvLaeuk Qo0c/N8cIgU6t/luIvmEYD0iJPWAMiTMKxhgPFBerzXkVS2/rrqP7ru12eEUGeNZyvmw DMkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ArJKO28hLj0K5VjH+0jBSnG6Yg4WWDwmTUVgCvjH65w=; b=LVAM144xZy1LVasq/a/AL8idvNZ/SUeRT/a22CXH+ErBIGQSkAWuCquRxne7z9ITfn EqSZEiVlU9v5iXdx2/x6fMqIpe1qb2lhFowAFhMZE4Qr6xcPhSLBxwNFUbk40ZXEzWlO 5yZncwxpKkeSFi1xL8L+a6v2a99s7KJP/InJ4kDUyIQEHedlOnnJNk5Aur2CAexWtl5I 42dEzjaNH3symOI9PcNN8ERTnA+6NtTpcZtXcRP202xFyCPE707eVjIjIPRWU5jo5rAX O66vTeCLJNiMjmr7Dy4zw6rGBGzG08/j6mdCKxLzFKyrhiBPX9TmVd7hfTUWSZXnUPFg NXwg== X-Gm-Message-State: AHQUAuYEbm/7gqUeRgD6iZLubtR58eXR7szhbCJv25KMtnYAG0og6FPH rZrMpFgPG5oREoHHgqFA6eNPHg== X-Google-Smtp-Source: AHgI3IboWsezZXt2jUW9T1YQEB3TlXlerh2SEmbx4xlZSlyYQWHNY+kFhIDOHowReaqMROsLDqpeRg== X-Received: by 2002:a17:902:765:: with SMTP id 92mr20443362pli.242.1549597459703; Thu, 07 Feb 2019 19:44:19 -0800 (PST) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id i4sm873275pfj.82.2019.02.07.19.44.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Feb 2019 19:44:18 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: stable@dpdk.org, Stephen Hemminger Date: Thu, 7 Feb 2019 19:44:03 -0800 Message-Id: <20190208034407.7865-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190208034407.7865-1-stephen@networkplumber.org> References: <20190208034407.7865-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] [PATCH 3/7] bus/vmbus: fix check for mmap failure 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: , X-List-Received-Date: Fri, 08 Feb 2019 03:44:20 -0000 From: Stephen Hemminger The code was testing the result of mmap incorrectly. I.e the test that a local pointer is not MAP_FAILED would always succeed and therefore hid any potential problems. Fixes: 831dba47bd36 ("bus/vmbus: add Hyper-V virtual bus support") Signed-off-by: Stephen Hemminger --- drivers/bus/vmbus/linux/vmbus_uio.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/bus/vmbus/linux/vmbus_uio.c b/drivers/bus/vmbus/linux/vmbus_uio.c index 09f7efdca286..8c6bc52fd475 100644 --- a/drivers/bus/vmbus/linux/vmbus_uio.c +++ b/drivers/bus/vmbus/linux/vmbus_uio.c @@ -202,6 +202,7 @@ static int vmbus_uio_map_subchan(const struct rte_vmbus_device *dev, char ring_path[PATH_MAX]; size_t file_size; struct stat sb; + void *mapaddr; int fd; snprintf(ring_path, sizeof(ring_path), @@ -232,14 +233,16 @@ static int vmbus_uio_map_subchan(const struct rte_vmbus_device *dev, return -EINVAL; } - *ring_size = file_size / 2; - *ring_buf = vmbus_map_resource(vmbus_map_addr, fd, - 0, sb.st_size, 0); + mapaddr = vmbus_map_resource(vmbus_map_addr, fd, + 0, file_size, 0); close(fd); - if (ring_buf == MAP_FAILED) + if (mapaddr == MAP_FAILED) return -EIO; + *ring_size = file_size / 2; + *ring_buf = mapaddr; + vmbus_map_addr = RTE_PTR_ADD(ring_buf, file_size); return 0; } -- 2.20.1