From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752235AbcL2B6p (ORCPT ); Wed, 28 Dec 2016 20:58:45 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:32433 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752095AbcL2B6n (ORCPT ); Wed, 28 Dec 2016 20:58:43 -0500 From: Kenneth Lee To: , , CC: , , , , , , , , , , , Subject: [PATCH] ib umem: bugfix: mixed put_pid()s in ib_umem_get() Date: Thu, 29 Dec 2016 10:24:43 +0800 Message-ID: <1482978283-201678-1-git-send-email-liguozhu@hisilicon.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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