Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp4428147ybe; Mon, 9 Sep 2019 09:08:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqxnl3PMdI8j16xaApayvFzYQct+4LfuerPiAvQ2kzUUiZecUxtNQjmrhe2P/NyMLYkH3cqe X-Received: by 2002:a17:906:244c:: with SMTP id a12mr19809856ejb.288.1568045290964; Mon, 09 Sep 2019 09:08:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568045290; cv=none; d=google.com; s=arc-20160816; b=GXlgam4u52Ym5sXX5kOCV1+KApzWQz8sCjorfMMRCYio2ivqrX3oGmcOla6SH05kFg kfylxvy3ZTsgn4Uj2EgNO9Ot2vFTPzapi5f8jSJLMmx/AhklJcd6qaN8FfCELeyCCgtj kK8lYvTXV/iT8LLa9/jCCL7amJOOkxxM7YRbJGuc4Qwr6XIc48lU7WPw+uHk/o4niyI9 l8BbUh5Y9uaSvZJisQZw83zAx19TzOQNtVHp3aCfaUj2DhMksFL7O0z2VNq2SQEaPq/L n7AzK7wYEHdsvy7sNILtEsjv47nFsnRCXFxLn0L2/6H9P+GTaVz3acTpcCr5/eu3sp67 L2AQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NjOh+Vt/fQd46wJbmq3c8qR7nFifa/WcOlPMkXWvY/Q=; b=fxcFiIDYVgBSSn0IOdRm2mafB3P91o8/iRjwmwx6fQLG8l3n3hjWEnd58iz/Cw2muQ yJymyXHlc4QHohJhRQWTrTa06sWiEb2nQUqsEapgzjdahEcD3df4f/EMuGbxgGqoYTEH OZgvK2ipgJ56e1JzGB6xIi6yZi2onKYYzuoR+vvWkoDOjTigEbFR3rSQDgek9O9OO0CF aCPbSkMqKsTENsFlNXroPOQOpTpqJUBc8NqfYcLOezXU0q6/zlt+4mg+XE409GuQzkMd 1iFjWSxTukfzUkUkB4urTgD6Ce7nUFAyc79F1kaFyxR7GCRq8IySDil904N7ShTENibb iCcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=k7KhGZ0Z; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y24si4235558ejb.344.2019.09.09.09.07.47; Mon, 09 Sep 2019 09:08:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=k7KhGZ0Z; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726341AbfIHM50 (ORCPT + 99 others); Sun, 8 Sep 2019 08:57:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:37460 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730985AbfIHMsW (ORCPT ); Sun, 8 Sep 2019 08:48:22 -0400 Received: from localhost (unknown [62.28.240.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7022B2190F; Sun, 8 Sep 2019 12:48:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567946902; bh=8svUIhnehzzECOzI2oNIKP/CjJxUGqIVc4hLamT4NC8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k7KhGZ0ZrzoznRRSvlezVlNBUJ39nKwXScAEpXUqcf2MFvvEX2p6I44KMD1OY61CL yYe0Gg1dIuDK8Sa2J/u/sAMqmyx1oJ4qkdC90J7EFuSnof3cOHq1IK45bBRpZDDS82 shYZ16x1rPVGtfOUqwmQ0MCPUinrDcnVNg9Klqao= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wenwen Wang , Leon Romanovsky , Doug Ledford , Sasha Levin Subject: [PATCH 4.19 44/57] IB/mlx4: Fix memory leaks Date: Sun, 8 Sep 2019 13:42:08 +0100 Message-Id: <20190908121145.131812089@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190908121125.608195329@linuxfoundation.org> References: <20190908121125.608195329@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 5c1baaa82cea2c815a5180ded402a7cd455d1810 ] In mlx4_ib_alloc_pv_bufs(), 'tun_qp->tx_ring' is allocated through kcalloc(). However, it is not always deallocated in the following execution if an error occurs, leading to memory leaks. To fix this issue, free 'tun_qp->tx_ring' whenever an error occurs. Signed-off-by: Wenwen Wang Acked-by: Leon Romanovsky Link: https://lore.kernel.org/r/1566159781-4642-1-git-send-email-wenwen@cs.uga.edu Signed-off-by: Doug Ledford Signed-off-by: Sasha Levin --- drivers/infiniband/hw/mlx4/mad.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c index e5466d786bb1e..5aaa2a6c431b6 100644 --- a/drivers/infiniband/hw/mlx4/mad.c +++ b/drivers/infiniband/hw/mlx4/mad.c @@ -1668,8 +1668,6 @@ tx_err: tx_buf_size, DMA_TO_DEVICE); kfree(tun_qp->tx_ring[i].buf.addr); } - kfree(tun_qp->tx_ring); - tun_qp->tx_ring = NULL; i = MLX4_NUM_TUNNEL_BUFS; err: while (i > 0) { @@ -1678,6 +1676,8 @@ err: rx_buf_size, DMA_FROM_DEVICE); kfree(tun_qp->ring[i].addr); } + kfree(tun_qp->tx_ring); + tun_qp->tx_ring = NULL; kfree(tun_qp->ring); tun_qp->ring = NULL; return -ENOMEM; -- 2.20.1