Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8125689imu; Tue, 4 Dec 2018 03:26:55 -0800 (PST) X-Google-Smtp-Source: AFSGD/UU4HqKxL03uF9VRuMM7XjIexIJPtVaY05qLKTfjLgOVtMQ3e4YnIQsYuHQmisSx85uaNgA X-Received: by 2002:a62:61c3:: with SMTP id v186mr8346282pfb.55.1543922815598; Tue, 04 Dec 2018 03:26:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543922815; cv=none; d=google.com; s=arc-20160816; b=TguVdvpWKSevn17AGOk+Z1WjbHWdixizdcdYeQ3scDhH8ztoPdoHa/pMPtRf3XI67R tk6Ze3PTMW58VYxJinHUwA/GVL8kROU5grHREW+Nhlii2aF/B0hQsQVZCsMxQDsXmylx qq0GEVnw4rPanecAe9h1GW7taPNFQ3skZqqDpy2LkxZe6941cSlUf+YmGoaugGZ+xyZI QMEkgKWoowNL9slWPEp4LnqtIysJzJNaas2kJ4Ulds0I7XiRlGQpwlUCxG+FfByszUUr 7g1CgNQZvkYgN5UoZqgx3lXHHfMoU5+PM1pLlXim+uXmoFiyfJnUjo/tuSBa1YCIBGUU 8gag== 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=6IQaVz3WZ6pAfG8kozl63NRjpFYZK2A0nVbN90tt80I=; b=bg6NTrX0HyPjlrgnqAt9+BXbu0IHhZIazi8sb7X0V10Tfrv10MN8VFxwiNAsqxRG0P VGTH5L8iDqD24EJpE/WvAOSh4+5NhpshtaywzvLIkuTPlAjfV5cGN/iRaVeanwaPS6f0 4qL2Vc2We3nDOGdBmQNDeFG5YA/MQvN+zieBhArK1CS6C2irfpnN1vP1noOp9DWYWYxg jYMm2LQ94bsZbW6Jc+QLdpQP+AxxcfCgxzXnsAeOaj06q5rrh5zBgC4/68mdPkfxCXrZ 6lVKysP2bapoCuJ/GWhs7TmxwuQQ8S4PskHhf9u04k31JhxK6ABOvUjY0bURqZcRAx8N +bIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oNffGgKZ; 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 g71si15138949pgc.419.2018.12.04.03.26.40; Tue, 04 Dec 2018 03:26:55 -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=oNffGgKZ; 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 S1727260AbeLDLAI (ORCPT + 99 others); Tue, 4 Dec 2018 06:00:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:45282 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726718AbeLDLAF (ORCPT ); Tue, 4 Dec 2018 06:00:05 -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 B5CED2146D; Tue, 4 Dec 2018 11:00:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543921205; bh=+qnvH0787AwjOTogfyfgiGr3EXKn6MgCIadywTxLI9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oNffGgKZjq7EARa/+yIJI9bFH7HFRC958DgkkCv+vlLkxOFJq+RPx1ka7AzkH0IVr gF7aecFo9/YoudJZZDxr4D/qQCG6Z8WrhPBvnEvkjyAG6yfaGjApeb6WDEQ9P4d7xx gp51bNZTKTHSFIhXVBAt83hTJJS0mDK4SCw94ulI= 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.19 122/139] dmaengine: at_hdmac: fix memory leak in at_dma_xlate() Date: Tue, 4 Dec 2018 11:50:03 +0100 Message-Id: <20181204103655.714571582@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181204103649.950154335@linuxfoundation.org> References: <20181204103649.950154335@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.19-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 @@ -1641,6 +1641,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"); } @@ -1675,7 +1681,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;