Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9089800pxu; Mon, 28 Dec 2020 06:23:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJzfBc5roFWevqcw0/ZTbF22JiyDJ8XuNHfK7+ltwvz2rMTmSkRc5L4mhY4O1KE+Ja4dAjez X-Received: by 2002:a17:906:d8a3:: with SMTP id qc3mr42029990ejb.443.1609165389778; Mon, 28 Dec 2020 06:23:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609165389; cv=none; d=google.com; s=arc-20160816; b=UUFSTHLz0Vdkmar5N0MSv9/MEX4bJ0dr1ZLs1Bzi8yje8BLL8uxrN5vA3g5ViTJvv8 vyBepXB720ZTz0gWHYgbjd1zP7O+6oMP60dTqOxlJ+uKBg0Vh4XJO5R343Euq53bhdIA 1VDtFQXiMdEjSx77J0kSYnDphT3gXxoiGOyxoz1qWIBCoKC0Ja8CZLMuFdhZwPHhexvr IIZDR4J+EWvQxx5EqZuedDl7bDDXCNWKj/ISFGL/yw4s1UKY5sqACVpoSaPikTsJHfQR tbze8dbtISkZHo/zcaMHzxfUHrsC4dte87up8RAkHuWJXbNOvAipbPHO/RMDu+x9zduJ epTA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VwdoQwS9d1m0Wmfcuy4xocvduuNfbrfhfxc0xGdLVnw=; b=Bs4NRdBf0D/lB4Zryag/rFB7/yg1MBMoPGZ4A3detkgMvcjdiY05Jx33rwwMvMPpib 6AUiXHSntOPNAhCvh7Apq7NWnAH4Lg1+ttI1LhGync2x9I8K/E/NChZReWJ9E1ugL9/t sXzCVGSON0lp0x1JgGVGU+O5DcnlTAfGGJbMJNcGKvQ0qZxVlP4V8MqKb1puXUA1hiqO GtRJ6Tjg5QaXgn6cB3X8iY+JoMHcs6cuKV8xMd1xDh0hCSKUbkI9NKp3iSCUm2QPTnEF HF7LosgQtHomyQgzoBHWc2W7chLTwF6shzFwDZXcCVZodTnIKps+e0Hsf71/zuXHd9al I5xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qWyxHz7F; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hr1si18888921ejc.474.2020.12.28.06.22.46; Mon, 28 Dec 2020 06:23:09 -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=@linuxfoundation.org header.s=korg header.b=qWyxHz7F; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407951AbgL1OUB (ORCPT + 99 others); Mon, 28 Dec 2020 09:20:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:54492 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392050AbgL1OT6 (ORCPT ); Mon, 28 Dec 2020 09:19:58 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 504362063A; Mon, 28 Dec 2020 14:19:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165177; bh=fvN/XZ2n5D6gRpYIFYl/cHckEs4tpp9ZV7jkXmARuy8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qWyxHz7FmKoS2kblyZAy+Dy6dFlp3bCeM22iyQeafv9X3DeAlQywYQVBcRIVOuSLo YEESVDPJJyPy126+lolrm3pWaJvPqOKNfIITwtWYdTNIoHP2dV1V3A1WatNXrsGU0g GEmI69IXLYwXdYhLypdOPWTjVpu48srr41M0htXA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maor Gottlieb , Leon Romanovsky , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.10 438/717] RDMA/mlx5: Fix MR cache memory leak Date: Mon, 28 Dec 2020 13:47:16 +0100 Message-Id: <20201228125041.953875660@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Maor Gottlieb [ Upstream commit e89938902927a54abebccc9537991aca5237dfaf ] If the MR cache entry invalidation failed, then we detach this entry from the cache, therefore we must to free the memory as well. Allcation backtrace for the leaker: [<00000000d8e423b0>] alloc_cache_mr+0x23/0xc0 [mlx5_ib] [<000000001f21304c>] create_cache_mr+0x3f/0xf0 [mlx5_ib] [<000000009d6b45dc>] mlx5_ib_alloc_implicit_mr+0x41/0×210 [mlx5_ib] [<00000000879d0d68>] mlx5_ib_reg_user_mr+0x9e/0×6e0 [mlx5_ib] [<00000000be74bf89>] create_qp+0x2fc/0xf00 [ib_uverbs] [<000000001a532d22>] ib_uverbs_handler_UVERBS_METHOD_COUNTERS_READ+0x1d9/0×230 [ib_uverbs] [<0000000070f46001>] rdma_alloc_commit_uobject+0xb5/0×120 [ib_uverbs] [<000000006d8a0b38>] uverbs_alloc+0x2b/0xf0 [ib_uverbs] [<00000000075217c9>] ksysioctl+0x234/0×7d0 [<00000000eb5c120b>] __x64_sys_ioctl+0x16/0×20 [<00000000db135b48>] do_syscall_64+0x59/0×2e0 Fixes: 1769c4c57548 ("RDMA/mlx5: Always remove MRs from the cache before destroying them") Link: https://lore.kernel.org/r/20201213132940.345554-2-leon@kernel.org Signed-off-by: Maor Gottlieb Signed-off-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/hw/mlx5/mr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c index 3468ae804eaee..971694e781b65 100644 --- a/drivers/infiniband/hw/mlx5/mr.c +++ b/drivers/infiniband/hw/mlx5/mr.c @@ -642,6 +642,7 @@ void mlx5_mr_cache_free(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr) if (mlx5_mr_cache_invalidate(mr)) { detach_mr_from_cache(mr); destroy_mkey(dev, mr); + kfree(mr); return; } -- 2.27.0