Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp802303imu; Tue, 11 Dec 2018 07:49:32 -0800 (PST) X-Google-Smtp-Source: AFSGD/WAglYgJrGRLO4Hm9Mz0ZrLwYIgd4Iqlcv9Int9LJ/EChcMC14tbtMNXNO2QMMvHF+nunV8 X-Received: by 2002:a17:902:29ab:: with SMTP id h40mr16372626plb.238.1544543371926; Tue, 11 Dec 2018 07:49:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544543371; cv=none; d=google.com; s=arc-20160816; b=Eiqf/S920scjZQV2A5/6lAY4RYFcspdJ+KJUo0fmfXOcDYOQP2F0IDCXFwnjOOI9BZ tXM0Nu0X3gATFj8FlgWBN70o3f8Fuz9Duf+I7QGzlQxl4eObSEJ7CMQiShnH4ho1pO8S GXvr9PdD3j2Zcq3kscr2rNQ9VhmuON5cnUCV1dxqAf29OjdeaRoskiuiFX35q6DXb/Ey QhgN1NWTHL9psI1Yk1w1CbU3zdkgqkSzJeGuH/QDwhdo63TwYfLK6cD3OgCvmZM3LKqA pry255Hr8aqcMnRPBLGS4mOl+nE9TXgXJulkptVkg+vpA7CPEOL6KiYB3SlanWL5ruaB GdpQ== 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=WQzrWUCIZEDOJdlPFaebQerOEevd+0LzMRSpyG2AYNk=; b=ncfE9ZEKbn13/sK0WQEmrPX2p8DfDtNg+474X6UUfaFmenoKP+qa8Rsp9nJ5QHIvLR 8NDqYQJKDEzYGZuo6uEXEH2V8/TIpGzgdh4X0I2KutKmudambDmGVFKHQtq9aBMMNgKH AhE3gl3TlaYY6s2WkWvoofo6fja4hBFqDNGLsIVG2kPgd5hA5ewJhmoHbkYETGF7zxjI w9hx1PXEha/49eps6rke+zZtqgEhAHnCurSaSPaXhRqNpdRhyXNS7nTVyHlSiTeNUlz9 2kcOTwHgRnivFsAUBWvhF7Sb6OYCUxYVar3yzL8PE/mnb8L5zB/8uBQ9+sjnve1cLrDq BMYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EHki8lFy; 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 d34si12991265pla.80.2018.12.11.07.48.54; Tue, 11 Dec 2018 07:49:31 -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=EHki8lFy; 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 S1728227AbeLKPp4 (ORCPT + 99 others); Tue, 11 Dec 2018 10:45:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:34252 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728199AbeLKPpy (ORCPT ); Tue, 11 Dec 2018 10:45:54 -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 051252087F; Tue, 11 Dec 2018 15:45:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544543153; bh=/uO9LvegOskOtYpNYJAyqXYSD9VwhWhBLsjwCBTgZJU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EHki8lFyWAIZBOm/+GEz6hrdVDZl92xrtwsv+PAuJZEKlkIkoOsdmnRkP2BI8LLJ0 JXMWzVr2tgjYzA19jTL30/F855pTpd2k6rMuR2C57xOJfK68R6hc+WQciAvHS4Mrhp sepPvLEQ7HUoD4h8dF1c45erxxUpQ/ldnLAE8q8c= 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.4 15/91] dmaengine: at_hdmac: fix memory leak in at_dma_xlate() Date: Tue, 11 Dec 2018 16:40:34 +0100 Message-Id: <20181211151607.136130436@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181211151606.026852373@linuxfoundation.org> References: <20181211151606.026852373@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.4-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 @@ -1781,6 +1781,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"); } @@ -1815,7 +1821,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;