All of lore.kernel.org
 help / color / mirror / Atom feed
From: Salil Mehta <salil.mehta-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
To: dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Cc: salil.mehta-hv44wF8Li93QT0dZR+AlfA@public.gmane.org,
	xavier.huwei-hv44wF8Li93QT0dZR+AlfA@public.gmane.org,
	oulijun-hv44wF8Li93QT0dZR+AlfA@public.gmane.org,
	yisen.zhuang-hv44wF8Li93QT0dZR+AlfA@public.gmane.org,
	xuwei5-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org,
	mehta.salil.lnk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linuxarm-hv44wF8Li93QT0dZR+AlfA@public.gmane.org,
	"Dongdong Huang(Donald)"
	<hdd.huang-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
Subject: [PATCH for-next 11/20] IB/hns: Fix bug of memory leakage for registering user mr
Date: Fri, 9 Sep 2016 18:30:42 +0800	[thread overview]
Message-ID: <1473417051-99560-12-git-send-email-salil.mehta@huawei.com> (raw)
In-Reply-To: <1473417051-99560-1-git-send-email-salil.mehta-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>

From: Lijun Ou <oulijun-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>

While the page size attribute of umem is illegal, we should release
umem that get by ib_umem_get interface.

Also, we should return a non-zero value while pbl number is wrong.

Signed-off-by: Lijun Ou <oulijun-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
Signed-off-by: Dongdong Huang(Donald) <hdd.huang-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
Reviewed-by:  Wei Hu (Xavier) <xavier.huwei-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
Signed-off-by: Salil Mehta <salil.mehta-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
---
 drivers/infiniband/hw/hns/hns_roce_mr.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/infiniband/hw/hns/hns_roce_mr.c b/drivers/infiniband/hw/hns/hns_roce_mr.c
index 59f5e2b..fb87883 100644
--- a/drivers/infiniband/hw/hns/hns_roce_mr.c
+++ b/drivers/infiniband/hw/hns/hns_roce_mr.c
@@ -564,11 +564,14 @@ struct ib_mr *hns_roce_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
 	if (mr->umem->page_size != HNS_ROCE_HEM_PAGE_SIZE) {
 		dev_err(dev, "Just support 4K page size but is 0x%x now!\n",
 			mr->umem->page_size);
+		ret = -EINVAL;
+		goto err_umem;
 	}
 
 	if (n > HNS_ROCE_MAX_MTPT_PBL_NUM) {
 		dev_err(dev, " MR len %lld err. MR is limited to 4G at most!\n",
 			length);
+		ret = -EINVAL;
 		goto err_umem;
 	}
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: Salil Mehta <salil.mehta@huawei.com>
To: <dledford@redhat.com>
Cc: <salil.mehta@huawei.com>, <xavier.huwei@huawei.com>,
	<oulijun@huawei.com>, <yisen.zhuang@huawei.com>,
	<xuwei5@hisilicon.com>, <mehta.salil.lnk@gmail.com>,
	<linux-rdma@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linuxarm@huawei.com>,
	"Dongdong Huang(Donald)" <hdd.huang@huawei.com>
Subject: [PATCH for-next 11/20] IB/hns: Fix bug of memory leakage for registering user mr
Date: Fri, 9 Sep 2016 18:30:42 +0800	[thread overview]
Message-ID: <1473417051-99560-12-git-send-email-salil.mehta@huawei.com> (raw)
In-Reply-To: <1473417051-99560-1-git-send-email-salil.mehta@huawei.com>

From: Lijun Ou <oulijun@huawei.com>

While the page size attribute of umem is illegal, we should release
umem that get by ib_umem_get interface.

Also, we should return a non-zero value while pbl number is wrong.

Signed-off-by: Lijun Ou <oulijun@huawei.com>
Signed-off-by: Dongdong Huang(Donald) <hdd.huang@huawei.com>
Reviewed-by:  Wei Hu (Xavier) <xavier.huwei@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
---
 drivers/infiniband/hw/hns/hns_roce_mr.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/infiniband/hw/hns/hns_roce_mr.c b/drivers/infiniband/hw/hns/hns_roce_mr.c
index 59f5e2b..fb87883 100644
--- a/drivers/infiniband/hw/hns/hns_roce_mr.c
+++ b/drivers/infiniband/hw/hns/hns_roce_mr.c
@@ -564,11 +564,14 @@ struct ib_mr *hns_roce_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
 	if (mr->umem->page_size != HNS_ROCE_HEM_PAGE_SIZE) {
 		dev_err(dev, "Just support 4K page size but is 0x%x now!\n",
 			mr->umem->page_size);
+		ret = -EINVAL;
+		goto err_umem;
 	}
 
 	if (n > HNS_ROCE_MAX_MTPT_PBL_NUM) {
 		dev_err(dev, " MR len %lld err. MR is limited to 4G at most!\n",
 			length);
+		ret = -EINVAL;
 		goto err_umem;
 	}
 
-- 
1.7.9.5

  parent reply	other threads:[~2016-09-09 10:30 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-09 10:30 [PATCH for-next 00/20] IB/hns: Fixes for various misc. bugs Salil Mehta
2016-09-09 10:30 ` Salil Mehta
2016-09-09 10:30 ` [PATCH for-next 01/20] IB/hns: Remove unused parameters in some functions Salil Mehta
2016-09-09 10:30   ` Salil Mehta
2016-09-09 10:30 ` [PATCH for-next 02/20] IB/hns: Remove parameters of resize cq Salil Mehta
2016-09-09 10:30   ` Salil Mehta
2016-09-09 10:30 ` [PATCH for-next 03/20] IB/hns: Add the check for pointer ctrl Salil Mehta
2016-09-09 10:30   ` Salil Mehta
     [not found]   ` <1473417051-99560-4-git-send-email-salil.mehta-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2016-09-15 10:07     ` Leon Romanovsky
2016-09-15 10:07       ` Leon Romanovsky
     [not found]       ` <20160915100757.GW26069-2ukJVAZIZ/Y@public.gmane.org>
2016-09-20 16:50         ` Salil Mehta
2016-09-20 16:50           ` Salil Mehta
2016-09-09 10:30 ` [PATCH for-next 04/20] IB/hns: Fix bug of using uninit refcount and free Salil Mehta
2016-09-09 10:30   ` Salil Mehta
2016-09-09 10:30 ` [PATCH for-next 05/20] IB/hns: Simplify function of pd alloc and qp alloc Salil Mehta
2016-09-09 10:30   ` Salil Mehta
2016-09-09 10:30 ` [PATCH for-next 06/20] IB/hns: Remove unused parameter named qp_type Salil Mehta
2016-09-09 10:30   ` Salil Mehta
2016-09-09 10:30 ` [PATCH for-next 07/20] IB/hns: Fix bug of clear hem Salil Mehta
2016-09-09 10:30   ` Salil Mehta
2016-09-09 10:30 ` [PATCH for-next 08/20] IB/hns: Delete the sqp_start from the structure hns_roce_caps Salil Mehta
2016-09-09 10:30   ` Salil Mehta
2016-09-09 10:30 ` [PATCH for-next 09/20] IB/hns: Optimize code of aeq and ceq interrupt handle and fix the bug of qpn Salil Mehta
2016-09-09 10:30   ` Salil Mehta
     [not found]   ` <1473417051-99560-10-git-send-email-salil.mehta-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2016-09-12 12:32     ` Leon Romanovsky
2016-09-12 12:32       ` Leon Romanovsky
     [not found]       ` <20160912123255.GG8812-2ukJVAZIZ/Y@public.gmane.org>
2016-09-12 15:47         ` Salil Mehta
2016-09-12 15:47           ` Salil Mehta
2016-09-09 10:30 ` [PATCH for-next 10/20] IB/hns: Modify the init of iboe lock Salil Mehta
2016-09-09 10:30   ` Salil Mehta
2016-09-13  6:50   ` Leon Romanovsky
     [not found]     ` <20160913065028.GR8812-2ukJVAZIZ/Y@public.gmane.org>
2016-09-14  2:09       ` Salil Mehta
2016-09-14  2:09         ` Salil Mehta
2016-09-14  5:04         ` Leon Romanovsky
     [not found]           ` <20160914050455.GY8812-2ukJVAZIZ/Y@public.gmane.org>
2016-09-15  3:49             ` Salil Mehta
2016-09-15  3:49               ` Salil Mehta
2016-09-09 10:30 ` [PATCH for-next 13/20] IB/hns: Add check for some NULL pointer scenes Salil Mehta
2016-09-09 10:30   ` Salil Mehta
2016-09-13  6:59   ` Leon Romanovsky
2016-09-15  3:41     ` Salil Mehta
2016-09-09 10:30 ` [PATCH for-next 15/20] IB/hns: Some items of qpc need to take user param Salil Mehta
2016-09-09 10:30   ` Salil Mehta
2016-09-09 10:30 ` [PATCH for-next 16/20] IB/hns: Validate mtu when modified qp Salil Mehta
2016-09-09 10:30   ` Salil Mehta
     [not found]   ` <1473417051-99560-17-git-send-email-salil.mehta-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2016-09-13  6:32     ` Leon Romanovsky
2016-09-13  6:32       ` Leon Romanovsky
     [not found]       ` <20160913063240.GO8812-2ukJVAZIZ/Y@public.gmane.org>
2016-09-14  2:07         ` Salil Mehta
2016-09-14  2:07           ` Salil Mehta
2016-09-09 10:30 ` [PATCH for-next 17/20] IB/hns: Cq has not been freed Salil Mehta
2016-09-09 10:30   ` Salil Mehta
     [not found] ` <1473417051-99560-1-git-send-email-salil.mehta-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2016-09-09 10:30   ` Salil Mehta [this message]
2016-09-09 10:30     ` [PATCH for-next 11/20] IB/hns: Fix bug of memory leakage for registering user mr Salil Mehta
2016-09-09 10:30   ` [PATCH for-next 12/20] IB/hns: Return bad wr while post send failed Salil Mehta
2016-09-09 10:30     ` Salil Mehta
     [not found]     ` <1473417051-99560-13-git-send-email-salil.mehta-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2016-09-15  9:07       ` Leon Romanovsky
2016-09-15  9:07         ` Leon Romanovsky
2016-09-20 16:46         ` Salil Mehta
2016-09-09 10:30   ` [PATCH for-next 14/20] IB/hns: The Ack timeout need a lower limit value Salil Mehta
2016-09-09 10:30     ` Salil Mehta
2016-09-09 10:30   ` [PATCH for-next 18/20] IB/hns: Update the rq head when modify qp state Salil Mehta
2016-09-09 10:30     ` Salil Mehta
     [not found]     ` <1473417051-99560-19-git-send-email-salil.mehta-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2016-09-15 10:12       ` Leon Romanovsky
2016-09-15 10:12         ` Leon Romanovsky
2016-09-20 16:56         ` Salil Mehta
2016-09-20 17:05           ` Leon Romanovsky
     [not found]             ` <20160920170553.GU26673-2ukJVAZIZ/Y@public.gmane.org>
2016-09-20 17:49               ` Salil Mehta
2016-09-20 17:49                 ` Salil Mehta
2016-09-09 10:30   ` [PATCH for-next 19/20] IB/hns: Fix the bug when platform_get_resource() exec fail Salil Mehta
2016-09-09 10:30     ` Salil Mehta
2016-09-09 10:30   ` [PATCH for-next 20/20] IB/hns: Delete the redundant lines in hns_roce_v1_m_qp() Salil Mehta
2016-09-09 10:30     ` Salil Mehta
     [not found]     ` <1473417051-99560-21-git-send-email-salil.mehta-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2016-09-15 10:15       ` Leon Romanovsky
2016-09-15 10:15         ` Leon Romanovsky
2016-09-20 16:57         ` Salil Mehta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1473417051-99560-12-git-send-email-salil.mehta@huawei.com \
    --to=salil.mehta-hv44wf8li93qt0dzr+alfa@public.gmane.org \
    --cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=hdd.huang-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linuxarm-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
    --cc=mehta.salil.lnk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=oulijun-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
    --cc=xavier.huwei-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
    --cc=xuwei5-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org \
    --cc=yisen.zhuang-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.