From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by dpdk.org (Postfix) with ESMTP id F28761B890 for ; Wed, 17 Apr 2019 20:45:16 +0200 (CEST) Received: by mail-pl1-f193.google.com with SMTP id y6so12467937plt.1 for ; Wed, 17 Apr 2019 11:45:16 -0700 (PDT) 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:mime-version :content-transfer-encoding; bh=FMPL/v8QaAc9jLAAfybfOgXZQ3DSPysCcCqHPH0+TPs=; b=wG1UUoDNBFdhvDwHJWsPsvLpz2xw05E08otZEoVByvQQ3sgt1P/8ISLQwihgGuyjSW 6S0eLUThi+TX2zxHao3hk6AwLg22dRgKTHZ9iQXdwTSeMOL+otSvCS1A3XBUpjvgks+9 gUsDeTWGZajGvmvKwRm0gM0ER8SY3ZVBO6nUzfuMzB7AUuEq+lhK03rqts7J2WV6jLZx Nkvi44x8GwtBF0ylVyiDbsH8b0eff2D8OHbDBKrK/UG0n0tx+FSi2ghxMFFP69FfOK2m GAGJRLBxBgXNGkihCvzmJCIVy5f2/qr404vyqP7kR6u8WUy1qlY3P1WspfX1O5D5Gefq KSEQ== 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:mime-version :content-transfer-encoding; bh=FMPL/v8QaAc9jLAAfybfOgXZQ3DSPysCcCqHPH0+TPs=; b=nhBhNBQJuvoKJNzugV7HKIHAcr/HOeWNKQ6HB6yfGh7BjnLTnPZDASUNaYjLVmhuDj /JwuTQ+8946lGfk4JOH2OJMGyiobrzN5dIba0t6j5zFuBUZx62R0NyrzvOHb6CrkYenS iiMGZ1kRYw9JSuxbQBRq5p+rMlPlkqMQ7ax+MdGzRccqxmSjFPvT+wKcoLghNY8HM8WC snJXJte5rIWzbDsfnFUCtlCvgHzFMoW4f8sL0tkFstNWwnp4LzXVM75FSJeP9bnQh0lE s+BkZUzGEYWzlGE9mWCFTgOGCr9BnKsB+CMcrkJgdnm4RgXSORaYIDpxT/3lSZYwdhrP l2mA== X-Gm-Message-State: APjAAAU2T2yK3yotz9wMC440uTcjnkI/T019M5+lZjN9Wv23RTKUvKWc IGkJm4x0x0nl0lPNrNhM7joZINO5k8o= X-Google-Smtp-Source: APXvYqzWnBzr51TR15ijN09oCGVr6BKtDYLGHIWms58+PUvyfGGXOVoSlO/KbELJhbYy22iAc+YMlQ== X-Received: by 2002:a17:902:e704:: with SMTP id co4mr50154726plb.30.1555526715684; Wed, 17 Apr 2019 11:45:15 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id t82sm145325801pfa.153.2019.04.17.11.45.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 11:45:14 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Stephen Hemminger Date: Wed, 17 Apr 2019 11:45:06 -0700 Message-Id: <20190417184506.18850-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] bus/vmbus: fix resource leak on error 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: , X-List-Received-Date: Wed, 17 Apr 2019 18:45:17 -0000 If secondary process attempt to mmap the resource resulted in the wrong address, then it would leave behind the bad mmap. Coverity issue: 337675, 337664 Signed-off-by: Stephen Hemminger --- drivers/bus/vmbus/linux/vmbus_uio.c | 4 +++- drivers/bus/vmbus/vmbus_common_uio.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/bus/vmbus/linux/vmbus_uio.c b/drivers/bus/vmbus/linux/vmbus_uio.c index fb60ee126d9b..be6b677f99d0 100644 --- a/drivers/bus/vmbus/linux/vmbus_uio.c +++ b/drivers/bus/vmbus/linux/vmbus_uio.c @@ -283,10 +283,12 @@ vmbus_uio_map_secondary_subchan(const struct rte_vmbus_device *dev, if (mapaddr == MAP_FAILED) VMBUS_LOG(ERR, "mmap subchan %u in secondary failed", chan->relid); - else + else { VMBUS_LOG(ERR, "mmap subchan %u in secondary address mismatch", chan->relid); + vmbus_unmap_resource(mapaddr, 2 * ring_size); + } return -1; } diff --git a/drivers/bus/vmbus/vmbus_common_uio.c b/drivers/bus/vmbus/vmbus_common_uio.c index 1aa5cb2e4b92..8e476f2eaf8b 100644 --- a/drivers/bus/vmbus/vmbus_common_uio.c +++ b/drivers/bus/vmbus/vmbus_common_uio.c @@ -75,9 +75,11 @@ vmbus_uio_map_secondary(struct rte_vmbus_device *dev) if (mapaddr == MAP_FAILED) VMBUS_LOG(ERR, "mmap resource %d in secondary failed", i); - else + else { VMBUS_LOG(ERR, "mmap resource %d address mismatch", i); + vmbus_unmap_resource(mapaddr, uio_res->maps[i].size); + } close(fd); return -1; -- 2.20.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id E9155A00E6 for ; Wed, 17 Apr 2019 20:45:19 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B5F6D1B893; Wed, 17 Apr 2019 20:45:18 +0200 (CEST) Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by dpdk.org (Postfix) with ESMTP id F28761B890 for ; Wed, 17 Apr 2019 20:45:16 +0200 (CEST) Received: by mail-pl1-f193.google.com with SMTP id y6so12467937plt.1 for ; Wed, 17 Apr 2019 11:45:16 -0700 (PDT) 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:mime-version :content-transfer-encoding; bh=FMPL/v8QaAc9jLAAfybfOgXZQ3DSPysCcCqHPH0+TPs=; b=wG1UUoDNBFdhvDwHJWsPsvLpz2xw05E08otZEoVByvQQ3sgt1P/8ISLQwihgGuyjSW 6S0eLUThi+TX2zxHao3hk6AwLg22dRgKTHZ9iQXdwTSeMOL+otSvCS1A3XBUpjvgks+9 gUsDeTWGZajGvmvKwRm0gM0ER8SY3ZVBO6nUzfuMzB7AUuEq+lhK03rqts7J2WV6jLZx Nkvi44x8GwtBF0ylVyiDbsH8b0eff2D8OHbDBKrK/UG0n0tx+FSi2ghxMFFP69FfOK2m GAGJRLBxBgXNGkihCvzmJCIVy5f2/qr404vyqP7kR6u8WUy1qlY3P1WspfX1O5D5Gefq KSEQ== 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:mime-version :content-transfer-encoding; bh=FMPL/v8QaAc9jLAAfybfOgXZQ3DSPysCcCqHPH0+TPs=; b=nhBhNBQJuvoKJNzugV7HKIHAcr/HOeWNKQ6HB6yfGh7BjnLTnPZDASUNaYjLVmhuDj /JwuTQ+8946lGfk4JOH2OJMGyiobrzN5dIba0t6j5zFuBUZx62R0NyrzvOHb6CrkYenS iiMGZ1kRYw9JSuxbQBRq5p+rMlPlkqMQ7ax+MdGzRccqxmSjFPvT+wKcoLghNY8HM8WC snJXJte5rIWzbDsfnFUCtlCvgHzFMoW4f8sL0tkFstNWwnp4LzXVM75FSJeP9bnQh0lE s+BkZUzGEYWzlGE9mWCFTgOGCr9BnKsB+CMcrkJgdnm4RgXSORaYIDpxT/3lSZYwdhrP l2mA== X-Gm-Message-State: APjAAAU2T2yK3yotz9wMC440uTcjnkI/T019M5+lZjN9Wv23RTKUvKWc IGkJm4x0x0nl0lPNrNhM7joZINO5k8o= X-Google-Smtp-Source: APXvYqzWnBzr51TR15ijN09oCGVr6BKtDYLGHIWms58+PUvyfGGXOVoSlO/KbELJhbYy22iAc+YMlQ== X-Received: by 2002:a17:902:e704:: with SMTP id co4mr50154726plb.30.1555526715684; Wed, 17 Apr 2019 11:45:15 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id t82sm145325801pfa.153.2019.04.17.11.45.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 11:45:14 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Stephen Hemminger Date: Wed, 17 Apr 2019 11:45:06 -0700 Message-Id: <20190417184506.18850-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] bus/vmbus: fix resource leak on error 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" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190417184506.8L3KnH6OBAv99V-TrNw3kZrverFq-7VPO5TfN16tFiE@z> If secondary process attempt to mmap the resource resulted in the wrong address, then it would leave behind the bad mmap. Coverity issue: 337675, 337664 Signed-off-by: Stephen Hemminger --- drivers/bus/vmbus/linux/vmbus_uio.c | 4 +++- drivers/bus/vmbus/vmbus_common_uio.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/bus/vmbus/linux/vmbus_uio.c b/drivers/bus/vmbus/linux/vmbus_uio.c index fb60ee126d9b..be6b677f99d0 100644 --- a/drivers/bus/vmbus/linux/vmbus_uio.c +++ b/drivers/bus/vmbus/linux/vmbus_uio.c @@ -283,10 +283,12 @@ vmbus_uio_map_secondary_subchan(const struct rte_vmbus_device *dev, if (mapaddr == MAP_FAILED) VMBUS_LOG(ERR, "mmap subchan %u in secondary failed", chan->relid); - else + else { VMBUS_LOG(ERR, "mmap subchan %u in secondary address mismatch", chan->relid); + vmbus_unmap_resource(mapaddr, 2 * ring_size); + } return -1; } diff --git a/drivers/bus/vmbus/vmbus_common_uio.c b/drivers/bus/vmbus/vmbus_common_uio.c index 1aa5cb2e4b92..8e476f2eaf8b 100644 --- a/drivers/bus/vmbus/vmbus_common_uio.c +++ b/drivers/bus/vmbus/vmbus_common_uio.c @@ -75,9 +75,11 @@ vmbus_uio_map_secondary(struct rte_vmbus_device *dev) if (mapaddr == MAP_FAILED) VMBUS_LOG(ERR, "mmap resource %d in secondary failed", i); - else + else { VMBUS_LOG(ERR, "mmap resource %d address mismatch", i); + vmbus_unmap_resource(mapaddr, uio_res->maps[i].size); + } close(fd); return -1; -- 2.20.1