Message ID | 20221220121139.1540564-1-linmq006@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp2929607wrn; Tue, 20 Dec 2022 04:13:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf5KbFAub7QlN3eh9TyaR2bOI065DcQKI53gH/xu8lrViGsdcYiokYU2ZGcDTZOYwijgDH6C X-Received: by 2002:a05:6a20:4387:b0:ac:f68:249a with SMTP id i7-20020a056a20438700b000ac0f68249amr57200415pzl.6.1671538409066; Tue, 20 Dec 2022 04:13:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671538409; cv=none; d=google.com; s=arc-20160816; b=uGFaVvK3uLGF5V5cBa5rUHD5y7b7AVtAVGG8fG4uY6W5eVR1UKugGuSK5e5XjjlGIH 8ZTvh8j7xDVaLpuxfBYmYoOB4dgcO5ji3phPHpnGtvfse/b1hTT5dS2e+xDuArngDJFD TRSwvNx4IWMnFZYmkCMj68hzerWJgPGnHissXiNJI/Tl+u7X3J9a65ooE+XOoTaww2Ji kxiZ02q8QgpDxcjKvXOL6HFzbv23pDupsJtZc6ulUpxYZX5qG/AtwEB78iXC4E/imwXJ nF0WFIa0+Jjj8465U6QxZHkMODtf0u3sYP3sZKcO//wUu6Q0G0HxsOP6oW0AyJaSUOC6 mWBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=/iqT075hnRTX9sxEK9bybY2wGmKzOFwkI+lpZrSw8cU=; b=ohvB2ytInEPyKKJ6ySyn6EnffpkhzQx5n3Y8V1BX6EwhjYpZftQywdwwCVCicJxr6U iG+80pW22S6l3HhxgPSNVDOjAlQdkEXIQZEzl72BLu0d2Oeh2Ej0IQvGRhLPbP33XGSC +roKmYqAFdT9UaOQIxye4GiM0GJrloLli0zywIcXz2+h9jhfqZmQZpJSHbUZamyGvLCe 9SIalYI2i/YNQSX6jmIVzD4k+e9TEjGR0chxlg85Y4Pz01/6WnSxZ9s2dxbG1Is0PDYT 2/mS1leTntTGOZd4nXAxjbgjxbqYsdTYlrMqc3ycnPjJHjJR5SjEEDx6dx9HcvCvMzrv 5AuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=nQpZPixp; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h71-20020a63834a000000b004573e877892si13844177pge.769.2022.12.20.04.13.16; Tue, 20 Dec 2022 04:13:29 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=nQpZPixp; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229749AbiLTML6 (ORCPT <rfc822;abdi.embedded@gmail.com> + 99 others); Tue, 20 Dec 2022 07:11:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229601AbiLTMLt (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 20 Dec 2022 07:11:49 -0500 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0590B15A03; Tue, 20 Dec 2022 04:11:49 -0800 (PST) Received: by mail-pf1-x42d.google.com with SMTP id x66so8378863pfx.3; Tue, 20 Dec 2022 04:11:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=/iqT075hnRTX9sxEK9bybY2wGmKzOFwkI+lpZrSw8cU=; b=nQpZPixpTkhHJ9tzM2er3cIgH65EF1oqkv9m79SZOfE3D3TUEAUPViwubl89wiSJbs TRPmoImnBCTYJ3rR/Vwd80OJ26UGUOa6CJmTKYsX3KsVFzuAcOKixQunUGwvSk+hd30Z qJ88zthuTbiwRMZYu1rZytSf2Q453q/TmuuaJupesf6qBRQdpv9DO+tUhym+asXpARUk /53+NwaxqpdCoZc5sFayIOSlc1mzijAOJHtRbK94aBDpUwArH4/w7MHyJCr5Rpa3LJrm wJ87qPoC6tzb6tUKSe8j7IB4bBzJKDnZX68V2DAgTxUsujqVZfTeidgFCNLamR3Ncqgf xvtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/iqT075hnRTX9sxEK9bybY2wGmKzOFwkI+lpZrSw8cU=; b=A46ZhXpRFm1WcpYO8J2HKCOiRQVCt21I72MBUn6Pbf6HaOZSBGiFhA087FDIFc8fx7 3cXj8IUNWqrOJQ1qTabiAz0TRAOls5vQDoRDeLgcRz4KEI16DF+fUbiEOBby6FahnjSG tdLjRzrQblghO9j3qcmDBe5rooFqeim+hOPvSMTIHvx1ZFPW64A92N3BXxBQp25eFlIP Su5gNS2Ez1nIhwab39GMV74noCdxPPXR/THHLynMO237KQAUybMZeQeq6o2SaNC7JwKa N9YO/cLGuJyLckcE49fQK66GzepkiVdVtTWCISKH6eCjWLg//fITg/UTizEaprdyNKHk ke/Q== X-Gm-Message-State: ANoB5pmf7fEYeSE3IhWKY64dpJiWy4tV4nByunqtJuwCXF03cMBLK7zw qJf+Vo2EibZpFU5CWQOViio= X-Received: by 2002:aa7:81ce:0:b0:577:6264:9d0f with SMTP id c14-20020aa781ce000000b0057762649d0fmr45671401pfn.6.1671538308477; Tue, 20 Dec 2022 04:11:48 -0800 (PST) Received: from localhost.localdomain ([202.120.234.246]) by smtp.googlemail.com with ESMTPSA id k18-20020aa79992000000b0056d7cc80ea4sm8525532pfh.110.2022.12.20.04.11.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Dec 2022 04:11:47 -0800 (PST) From: Miaoqian Lin <linmq006@gmail.com> To: Cheng Xu <chengyou@linux.alibaba.com>, Kai Shen <kaishen@linux.alibaba.com>, Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>, Wei Yongjun <weiyongjun1@huawei.com>, Yang Li <yang.lee@linux.alibaba.com>, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linmq006@gmail.com Subject: [PATCH] RDMA/erdma: Fix refcount leak in erdma_mmap Date: Tue, 20 Dec 2022 16:11:39 +0400 Message-Id: <20221220121139.1540564-1-linmq006@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752735058908431235?= X-GMAIL-MSGID: =?utf-8?q?1752735058908431235?= |
Series |
RDMA/erdma: Fix refcount leak in erdma_mmap
|
|
Commit Message
Miaoqian Lin
Dec. 20, 2022, 12:11 p.m. UTC
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 <linmq006@gmail.com>
---
drivers/infiniband/hw/erdma/erdma_verbs.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Comments
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 <linmq006@gmail.com> > --- > drivers/infiniband/hw/erdma/erdma_verbs.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > Good catch, thanks. Acked-by: Cheng Xu <chengyou@linux.alibaba.com> > 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; > }
On Tue, 20 Dec 2022 16:11:39 +0400, 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. > > Applied, thanks! [1/1] RDMA/erdma: Fix refcount leak in erdma_mmap https://git.kernel.org/rdma/rdma/c/ee84146c05ad23 Best regards,
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; }