Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp630310pxv; Thu, 15 Jul 2021 11:59:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwi3dAdn4Ro/BMd9CVylLYSiwmxXuzPUya3DE3UztV/xkGnuepqMHXs05EJJlyS3acok2zY X-Received: by 2002:a05:6602:2219:: with SMTP id n25mr4167569ion.205.1626375553407; Thu, 15 Jul 2021 11:59:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626375553; cv=none; d=google.com; s=arc-20160816; b=UNUaHr0SrIgRA8TdtUZFzBpCU4aQxiPsndkJFUVjFo1OPHHi7bN8Ns45O0TK73tIlL 8nm2nfdpF1vRKmgqBh73dzcI5RfywPhuy/ElO7xvdzZ3BQLR2Ln+uAthrtVlzta//a96 eJ9u4wyrMP6WT+MV1mlPX/ShBMwHj6k1OTYTc44G20joQMITWsI9y4Kh+ctquQAfoIIi Q4dK+b4qYD8SKHy3yH0WSlbw+LsgQrc+FF7V4iofZQxLyMFnPcRWIJsXUdaoyOMGAjbS w8DS4gR1Maz4C8ztTdy8ZJnzERErUSWBZI2I5vV1egcUL/9eoNgANu2w03F7voVrbHJU UEoQ== 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=W1Z4HSZmabGXr9i83tHBa80lJSPfl+uZvs7SvWXICXs=; b=n7bn4OZY18hkLD4uNAWhTJheexvfD7ng86g0t8XuDvujBmbc8zJlUVA0jqI8+KMOlV 0D5t+UsoDKSsIoB18XiA/C8tu+seQNJRp3rCip2sKVl2YqrkmXjFKsARrhYKL6jOhkMt ASN3oQ7hDoSdMfvnmcHr3ULCpIHwivVjb0XESosHwGi/FfliDkDRpKwWgZFAzmSiilmV JoJKRWctqF46e+KTnpsHWV+s1KB3EyN+5IzPypxdcaxT8H9znGJqX6ymduShrQWu1LOz UfnZtWkr3fYuGgGH+Ig8CloznP+578fLsbKh6M1rJ3nuHY2Vt15hO6RvwETHu8lYQdDX XgtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kY2rXex2; 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 y15si6504597ilv.136.2021.07.15.11.59.00; Thu, 15 Jul 2021 11:59:13 -0700 (PDT) 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=kY2rXex2; 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 S242498AbhGOS7n (ORCPT + 99 others); Thu, 15 Jul 2021 14:59:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:55914 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239831AbhGOSws (ORCPT ); Thu, 15 Jul 2021 14:52:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3052C613D9; Thu, 15 Jul 2021 18:49:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626374994; bh=YG0qm79BroaI6CylnQisfmeMk0+lZCDIprASKU7iuVc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kY2rXex2LS47ZeLTsfscP3XjO03S9oSSlbONiXrkcD1nnTUPfh44S1WfkFqGMaBx1 /t7DgBT+ogy1HLIIyFrUEWxPdQApvem0uQO473HXgTNVqDWVacQmJpGZx8cSU5ZNLT y9pejqJFfnqMSHcT3q4eyawtEMV0cImGxJhzyVCc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gerd Rausch , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.10 115/215] RDMA/cma: Fix rdma_resolve_route() memory leak Date: Thu, 15 Jul 2021 20:38:07 +0200 Message-Id: <20210715182619.899457746@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182558.381078833@linuxfoundation.org> References: <20210715182558.381078833@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: Gerd Rausch [ Upstream commit 74f160ead74bfe5f2b38afb4fcf86189f9ff40c9 ] Fix a memory leak when "mda_resolve_route() is called more than once on the same "rdma_cm_id". This is possible if cma_query_handler() triggers the RDMA_CM_EVENT_ROUTE_ERROR flow which puts the state machine back and allows rdma_resolve_route() to be called again. Link: https://lore.kernel.org/r/f6662b7b-bdb7-2706-1e12-47c61d3474b6@oracle.com Signed-off-by: Gerd Rausch Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/core/cma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 0c879e40bd18..34b94e525390 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -2793,7 +2793,8 @@ static int cma_resolve_ib_route(struct rdma_id_private *id_priv, cma_init_resolve_route_work(work, id_priv); - route->path_rec = kmalloc(sizeof *route->path_rec, GFP_KERNEL); + if (!route->path_rec) + route->path_rec = kmalloc(sizeof *route->path_rec, GFP_KERNEL); if (!route->path_rec) { ret = -ENOMEM; goto err1; -- 2.30.2