Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp5052757rwj; Tue, 20 Dec 2022 19:45:35 -0800 (PST) X-Google-Smtp-Source: AMrXdXuaZ12QhxeeFguhqx9KJJd1BeNF5hU4p7fvqvGoGy2zC/iHxwUpv4oxOVRC5ntGm72xqDAB X-Received: by 2002:a05:6a20:8f1c:b0:a9:d06b:ef2 with SMTP id b28-20020a056a208f1c00b000a9d06b0ef2mr1051940pzk.36.1671594335360; Tue, 20 Dec 2022 19:45:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671594335; cv=none; d=google.com; s=arc-20160816; b=IZPPUG5qIM+yZ5Vfls0X0zgb66x7gNcAOL593e0fgf08b+uMNv4uK+Q7BY6Z/wBWf3 dRwq3zsBQy5x2QvVPeIbN/SMIu4QsfgxAknPMA+qkHfAp3ZrgGIamgHBzdYS9CgZncrW hNZksYsk59vNCRVjWI3z+XVhxJa2uFmpcH/lvpX1zGK8bIWKy0mP8eijiVjcLWnqz0G7 CRGtWtv1gNtYy+ga4rpyS55jmfN2+f3DI7ha37vviOSss5RlrwGBEJj0hd7c/v9oPHZH 2jPli0VHSYE69YLH9JQjTvY3Jevqx3c+lXQsIMUm5Ml8XllL0SDXhm9XHuQjxRsQ57bx obuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:to:subject:user-agent:mime-version:date :message-id; bh=bodV5oOEoBqoenz3MmLs4n4JBA8HvdfdyWH6dbus3m0=; b=dUCRncf7cRJoAc3A3Dv4P5mMzh1MFVDckoyeALiaNEZNjst3y2u4sZvzBcN5TTdVhD fH+XzThwJ7SjTWnRXmSyl2d0hnZDEfU8BtzvRXnYygmOmYr5jxITOLs1P+sjF4fn+E5c zwVaI4sbFOlvHScL1ZioUbEaCkJsgAtT8Lcm+nmg7qlWxRIsr17BhaydayTFEM6enS/U ZWqcQY6pdgljd6q+wVKSiHAkAb/dUvWrldzWfNL7Eij0Q1mKGcCK/QzBlq9fpT56L1Ew FOdTqGWJqi2lMl5l7daWGahgrqNIGoDDiCfVedL3TCfp/e0AhCcVu+q5YwfBjYlI/cNc 6z7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s11-20020a056a00178b00b0056dc16897d7si15477056pfg.15.2022.12.20.19.45.26; Tue, 20 Dec 2022 19:45:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234100AbiLUC6q (ORCPT + 69 others); Tue, 20 Dec 2022 21:58:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229702AbiLUC6m (ORCPT ); Tue, 20 Dec 2022 21:58:42 -0500 Received: from out30-45.freemail.mail.aliyun.com (out30-45.freemail.mail.aliyun.com [115.124.30.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E0EB1A22A; Tue, 20 Dec 2022 18:58:40 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R111e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045170;MF=chengyou@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0VXnbglx_1671591517; Received: from 30.221.97.245(mailfrom:chengyou@linux.alibaba.com fp:SMTPD_---0VXnbglx_1671591517) by smtp.aliyun-inc.com; Wed, 21 Dec 2022 10:58:38 +0800 Message-ID: Date: Wed, 21 Dec 2022 10:58:35 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH] RDMA/erdma: Fix refcount leak in erdma_mmap To: Miaoqian Lin , Kai Shen , Jason Gunthorpe , Leon Romanovsky , Wei Yongjun , Yang Li , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org References: <20221220121139.1540564-1-linmq006@gmail.com> Content-Language: en-US From: Cheng Xu In-Reply-To: <20221220121139.1540564-1-linmq006@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/20/22 8:11 PM, Miaoqian Lin wrote: > rdma_user_mmap_entry_get() take reference, we should release it when not > need anymore, add the missing rdma_user_mmap_entry_put() in the error > path to fix it. > > Fixes: 155055771704 ("RDMA/erdma: Add verbs implementation") > Signed-off-by: Miaoqian Lin > --- > drivers/infiniband/hw/erdma/erdma_verbs.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > Good catch, thanks. Acked-by: Cheng Xu > diff --git a/drivers/infiniband/hw/erdma/erdma_verbs.c b/drivers/infiniband/hw/erdma/erdma_verbs.c > index 5dab1e87975b..9c30d78730aa 100644 > --- a/drivers/infiniband/hw/erdma/erdma_verbs.c > +++ b/drivers/infiniband/hw/erdma/erdma_verbs.c > @@ -1110,12 +1110,14 @@ int erdma_mmap(struct ib_ucontext *ctx, struct vm_area_struct *vma) > prot = pgprot_device(vma->vm_page_prot); > break; > default: > - return -EINVAL; > + err = -EINVAL; > + goto put_entry; > } > > err = rdma_user_mmap_io(ctx, vma, PFN_DOWN(entry->address), PAGE_SIZE, > prot, rdma_entry); > > +put_entry: > rdma_user_mmap_entry_put(rdma_entry); > return err; > }