Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp5274630pxb; Sun, 7 Nov 2021 08:46:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJyt9/nxkEYHdi0f9MTGQqaL288TTqJKBKCRbIFzpsqHeAqbbsGLt0U7d5KyHuLTr1XqHDDY X-Received: by 2002:a05:6602:2d49:: with SMTP id d9mr8762135iow.11.1636303616641; Sun, 07 Nov 2021 08:46:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636303616; cv=none; d=google.com; s=arc-20160816; b=diQnjV3Z+ZbeYbDnePkwir4mESfAHedtznXsMSEIlOIT/8DqPUjfV16JbYvgZoeeoP 3dcj1WgNGZFYC21GU/qmwvrGJ54gmMWzznzsYLcGkqWz7oDP7/bBrhzdGRUIZnoziELj zG02ozhob+YKD9W9dm+0XUqmkW8tY4G7lQ0ck2ZOTC04tZaOBh84MqrBYiXQVBT//wtP GKHa6qvHB3tC8j3WiKXkPZKyK8FoykQKTLrEoOFm8/kOsnMg9PGIz11Sew9E8khkPdqB 4cgAFknvOpTNkIw3AAg4/A5EGA30lx5yu8S2zEyVsNJKMxsPkvxOj+Vr64rFp/HmtFgR aHCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=fbQ9a4qhktBhq1fmKaMF4Ewup/8KjssvCMjNoENckPU=; b=v3EkmprXwgl+3LEPGCKwKBMEmgZ/mUNgA5tOAEAnmZ7JzCoKzAr1lcwMxaFrnPTb45 U8spOLNmhPhFtJ79DkcGCCF20KjRoJhTdu1QzW4K9gexc1re24aTJkE8kN1Pvtn3S7Od hj8FxeHhs1snQEB+bfY071EwUNUUyJLjStoeWgIavG3ywYOsCLHy/AK0S2rM4oECKnCl OIVsl8ogbQrEFv1dYE/5gQ32EvEz3ehdmnBY23vKlCqVkOF/L67XYsvsnxtp2YXk81Vo qQSrlZrn7oo8L5qWQxy3ypXx7v11ldOhBOhWA5tXhbdvfhxzvqO+fczO/BOeFi9Ol0Dd 4mqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Y83LSuQD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w12si19788765ilg.168.2021.11.07.08.46.33; Sun, 07 Nov 2021 08:46:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Y83LSuQD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234926AbhKGHmr (ORCPT + 99 others); Sun, 7 Nov 2021 02:42:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:39082 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234272AbhKGHmq (ORCPT ); Sun, 7 Nov 2021 02:42:46 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id C3675613AC; Sun, 7 Nov 2021 07:40:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636270804; bh=xK7EWfUT/HcNYKPKVTyFRCEn67drZQu6TfoeV5SB8wg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Y83LSuQDcfps1yh5CmqlTsWUZCUVhFxv0r7t5ZkQbyfhpmy+jYmBzjae/ZAI6uDLj 1VLmVaWEZ/6PgBVSETy4GQTkLJ0Wqm+jbXPktorPvEZzKUTrvcE/v7L6irnlM+kXuf rN4Q2hWCdIDGke6u/3n3mVmxk9OQhnj4NUMVPR3OwWUcT0S4smEa1O2eHOj7dEw4Wl g/3Ot3A2Vjgw3Omh5Yy7oFk7VKybaZSzL4ZRSSjhWp+Gn+R0lIcLoX+buVTuOAQYoW Il9MS2y0Nr8TRuGkjtzqsW22RCyKiylGj8CXy1lRWorTaNmXGQATlZ9LaDDZcPmzwR hTJsgC7n8SMvg== Date: Sun, 7 Nov 2021 09:40:00 +0200 From: Leon Romanovsky To: Jiasheng Jiang Cc: yishaih@nvidia.com, dledford@redhat.com, jgg@ziepe.ca, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] RDMA/mlx4: Fix potential memory leak Message-ID: References: <1636020852-3951757-1-git-send-email-jiasheng@iscas.ac.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1636020852-3951757-1-git-send-email-jiasheng@iscas.ac.cn> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 04, 2021 at 10:14:12AM +0000, Jiasheng Jiang wrote: > In the error path, the dev->dev isn't released. > Therefore, it might be better to fix it to avoid > potential memory leak. > > Fixes: 9376932 ("IB/mlx4_ib: Add support for user MR re-registration") > Signed-off-by: Jiasheng Jiang > --- > drivers/infiniband/hw/mlx4/mr.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) I don't understand about which release you are talking, but this patch can't be right. You are supposed to call to "release_mpt_entry" only in the error flows which after successful mlx4_mr_hw_get_mpt(). Thanks > > diff --git a/drivers/infiniband/hw/mlx4/mr.c b/drivers/infiniband/hw/mlx4/mr.c > index 50becc0..d8ae92e 100644 > --- a/drivers/infiniband/hw/mlx4/mr.c > +++ b/drivers/infiniband/hw/mlx4/mr.c > @@ -473,7 +473,7 @@ struct ib_mr *mlx4_ib_rereg_user_mr(struct ib_mr *mr, int flags, u64 start, > */ > err = mlx4_mr_hw_get_mpt(dev->dev, &mmr->mmr, &pmpt_entry); > if (err) > - return ERR_PTR(err); > + goto release_mpt_entry; > > if (flags & IB_MR_REREG_PD) { > err = mlx4_mr_hw_change_pd(dev->dev, *pmpt_entry, > -- > 2.7.4 >