Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp797084imu; Tue, 11 Dec 2018 07:44:45 -0800 (PST) X-Google-Smtp-Source: AFSGD/UdYPAdLaL1DTRaNmWkQONeWXVn9q6MlvlXs440gKAMoiuzhT9qfDCeg7MVf1vFvX3hL+LW X-Received: by 2002:a63:9501:: with SMTP id p1mr15186018pgd.149.1544543085871; Tue, 11 Dec 2018 07:44:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544543085; cv=none; d=google.com; s=arc-20160816; b=moTd13/xOOqrnFua5G0svFtJT8jbMylgBSGmoE2bbsN+voAid3BLawesA2KDPjO/cG VWS+JebU8MOjTPZ49IM4jI/xKQ/Ua34S9Kzj83u0pmdimh2yLGBfa6ydnR+Z2dcwuxeL MKv5ltOHM/C+KvadDS4TlcfzOIY9nJwoNvrHZmvn6Ru/+02ypWNRcxOL6biwRwsUNbMO rz6LWbdItPh6GHMMrLc/v5BbC+abkdTHl/MEeKUgQTK85PcAY2JyZu40lAWPkoN0e1a9 TI+EavNIrsxVDqQ+XSEwPYfZUtikxznSrtWIOt7ge7CnXxeG5bat/grKIznfwjUGPhIJ zAig== 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=Xmht8PZN5+GFk+Gbxave82/dLrRluYAJ1jX+g94uvPk=; b=ocnhsmvHWRCUsHTyc6A+5R22oemZO5R6nRuRvvsqpbRsaTny1a32l7CnZ+2ROhkBpq O7PbK2KTYn+6XzPYeJPjdanHBrdfyngXPXdIn49lDCe7c86r10RGb7xlPwmFkadWLzt1 UcPKZ5GZXKsX5geL7RPLYzG7C6JfMJUy2qGR/rbMytyW1BRArKX1uVRtTl5L77cYH8BH 4etFl6m6Yghn3P3czBlFthYdSO22IS02KZv6SHQlldtBxEhH2l54pybYydws1xLn28qD uaHg8TUw/LDTYR0X6S9qNDVbFFsc8v2FW5JJakLNi7BaDB2a0oLhC2ruDRN9u8Wvb+b1 TIdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QD18NHb2; 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 w185si13926688pfw.122.2018.12.11.07.44.30; Tue, 11 Dec 2018 07:44:45 -0800 (PST) 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=QD18NHb2; 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 S1727484AbeLKPnR (ORCPT + 99 others); Tue, 11 Dec 2018 10:43:17 -0500 Received: from mail.kernel.org ([198.145.29.99]:59720 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727473AbeLKPnP (ORCPT ); Tue, 11 Dec 2018 10:43:15 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 B0C55208E7; Tue, 11 Dec 2018 15:43:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544542995; bh=ySb37fN7qESseO3/QjgNILzU3A15PrGjWQJsHQpWViI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QD18NHb20l41Tm9w1a7isV4iUu1HGgkiXEgaFzZQE7685sGeKgyDYO+CpAYLsKxbT 5p3Y1acxQ/KtTMk4PGjGes+f8O0GmTUIOtVlnZc7/7ne84WMa3Gf4wMyVs3D5u5vFL zKJI00iiKZgqj83+yIFRYcTvntA+HQSTbxNOq+s4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mario Forner , Alexandre Belloni , Ludovic Desroches , Richard Genoud , Vinod Koul Subject: [PATCH 3.18 09/54] dmaengine: at_hdmac: fix memory leak in at_dma_xlate() Date: Tue, 11 Dec 2018 16:40:57 +0100 Message-Id: <20181211151546.497323659@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181211151546.010073210@linuxfoundation.org> References: <20181211151546.010073210@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Richard Genoud commit 98f5f932254b88ce828bc8e4d1642d14e5854caa upstream. The leak was found when opening/closing a serial port a great number of time, increasing kmalloc-32 in slabinfo. Each time the port was opened, dma_request_slave_channel() was called. Then, in at_dma_xlate(), atslave was allocated with devm_kzalloc() and never freed. (Well, it was free at module unload, but that's not what we want). So, here, kzalloc is more suited for the job since it has to be freed in atc_free_chan_resources(). Cc: stable@vger.kernel.org Fixes: bbe89c8e3d59 ("at_hdmac: move to generic DMA binding") Reported-by: Mario Forner Suggested-by: Alexandre Belloni Acked-by: Alexandre Belloni Acked-by: Ludovic Desroches Signed-off-by: Richard Genoud Signed-off-by: Vinod Koul Signed-off-by: Greg Kroah-Hartman --- drivers/dma/at_hdmac.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/drivers/dma/at_hdmac.c +++ b/drivers/dma/at_hdmac.c @@ -1232,6 +1232,12 @@ static void atc_free_chan_resources(stru atchan->status = 0; atchan->remain_desc = 0; + /* + * Free atslave allocated in at_dma_xlate() + */ + kfree(chan->private); + chan->private = NULL; + dev_vdbg(chan2dev(chan), "free_chan_resources: done\n"); } @@ -1266,7 +1272,7 @@ static struct dma_chan *at_dma_xlate(str dma_cap_zero(mask); dma_cap_set(DMA_SLAVE, mask); - atslave = devm_kzalloc(&dmac_pdev->dev, sizeof(*atslave), GFP_KERNEL); + atslave = kzalloc(sizeof(*atslave), GFP_KERNEL); if (!atslave) return NULL;