Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8113474imu; Tue, 4 Dec 2018 03:13:56 -0800 (PST) X-Google-Smtp-Source: AFSGD/UUYlPtWm6zC12PPn3SsYiV0o9PrRvybvUU6gaPMRal0AifQfmoffqXhbDmURzOfZaJBHG9 X-Received: by 2002:a63:6483:: with SMTP id y125mr4083616pgb.91.1543922036342; Tue, 04 Dec 2018 03:13:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543922036; cv=none; d=google.com; s=arc-20160816; b=c7MRpkC6GEuYvVSA3lN8Mpo+1ClOwMz+QI7syzqSxE3rBH2sRS4qHsJS9VclYV9CSw lfu3AL15yXSusY8pgK72zyR4/da+POSRwFY9V68URkZYSc4nsRQtoFn7Pskj4KdV3ZN8 AO6o1dKNcHqgL0AJeujTZ99LZ+5L7E/y6E3L36PV3XOe1tEWlq7cHaOJ6HjJVc8d5GNI fHse/jn1imwtFhhUcdE1IuaXdvipOQdble3GbR1qT8PWwlq7tL/qa7BEQ0LOsHmoQz5s NVm+p2HIFekRubF2qyYffmMw9GmnOY8v07zRik872ywBA8DPlecE916IZyyDT5jBEAEI WWhg== 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=BR7wMqZPJGT5l3swkQnGF6XEymOwVZasO2k6fXxuo30=; b=QcjgyLQn3jnmhEEf9mYs6Vv5JuCLouHtcTiwLWx/XXOVokY84yD1+RAj3+LcJsX32N 4B3ZQugjQqpko3/hXj6yVIwNQqAnvS6LHVsg2BrA4Bg+pce46mdiV5xMOpno7C/d1IfD U7465ONFmKDEP9Qs3YirzQzlOtyKzuV3PSgD4qu2AJMO7kX7086HTZ6SN5IBC59MkVoL GVKYLL7ysrqgE8xWeVU2yk1IsWpXRxmspww1cR1sY8gWYmhoINc3F/z+lqWgwvQoSWF0 I7Z53XYSuc99piiBfUlcbncWP9cprM9P7mJcK2BzmWF972mmZ9zFRScJdQTWsBnU9nuy MIoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=J6mceQWk; 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 e15si14751952pgg.281.2018.12.04.03.13.41; Tue, 04 Dec 2018 03:13:56 -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=J6mceQWk; 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 S1728670AbeLDLIr (ORCPT + 99 others); Tue, 4 Dec 2018 06:08:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:58234 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728667AbeLDLIo (ORCPT ); Tue, 4 Dec 2018 06:08:44 -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 A6815214DA; Tue, 4 Dec 2018 11:08:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543921723; bh=M+m0Z5HfsJWhNwKUmnD4gcCI7Zt1WEk7EZSjlEE5NFA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J6mceQWkVHBYtr73EhZ2UVeE006IIlwe1+FRAZlLBNaDPxtWrjbLKSBQPUG3Mi+Ad jUrEVFCXGgYG4f/1Hyuk1uSykJam97OP3KAF8erEx0eAK8A3Ns3nrt5Qj8FkAM4Oy9 R6qbmrPqUuDV+mT4Xsp7WsvdxRyi0t2pqgKR5530= 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 4.9 33/50] dmaengine: at_hdmac: fix memory leak in at_dma_xlate() Date: Tue, 4 Dec 2018 11:50:28 +0100 Message-Id: <20181204103716.157406252@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181204103714.485546262@linuxfoundation.org> References: <20181204103714.485546262@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 4.9-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 @@ -1774,6 +1774,12 @@ static void atc_free_chan_resources(stru atchan->descs_allocated = 0; atchan->status = 0; + /* + * Free atslave allocated in at_dma_xlate() + */ + kfree(chan->private); + chan->private = NULL; + dev_vdbg(chan2dev(chan), "free_chan_resources: done\n"); } @@ -1808,7 +1814,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;