From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752595AbcL2ICQ (ORCPT ); Thu, 29 Dec 2016 03:02:16 -0500 Received: from szxga01-in.huawei.com ([58.251.152.64]:10203 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752359AbcL2ICP (ORCPT ); Thu, 29 Dec 2016 03:02:15 -0500 From: Kenneth Lee To: , , CC: , , , , , , , , , , , Subject: [PATCH v2] ib umem: bugfix: mixed put_pid()s in ib_umem_get() Date: Thu, 29 Dec 2016 16:27:28 +0800 Message-ID: <1483000048-183875-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 Reviewed-by: Haggai Eran --- 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