[PATCH v2] ib umem: bugfix: mixed put_pid()s in ib_umem_get()

From: Kenneth Lee
Date: Thu Dec 29 2016 - 03:02:19 EST


There are two bugfixes in this patch:

1. When the execution go to the ib_umem_odp_get() path, pid should be put
back.
2. When the memory allocation fail, the pid also should be put back before
exit.

Signed-off-by: Kenneth Lee <liguozhu@xxxxxxxxxxxxx>
Reviewed-by: Haggai Eran <haggaie@xxxxxxxxxxxx>
---
Change from v1 to v2:
Correcting the patch title and description

drivers/infiniband/core/umem.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
index 1e62a5f..4609b92 100644
--- a/drivers/infiniband/core/umem.c
+++ b/drivers/infiniband/core/umem.c
@@ -134,6 +134,7 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
IB_ACCESS_REMOTE_ATOMIC | IB_ACCESS_MW_BIND));

if (access & IB_ACCESS_ON_DEMAND) {
+ put_pid(umem->pid);
ret = ib_umem_odp_get(context, umem);
if (ret) {
kfree(umem);
@@ -149,6 +150,7 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,

page_list = (struct page **) __get_free_page(GFP_KERNEL);
if (!page_list) {
+ put_pid(umem->pid);
kfree(umem);
return ERR_PTR(-ENOMEM);
}
--
1.9.1