Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp965372pxu; Wed, 6 Jan 2021 08:53:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJxRoOOpDCx0Crup4xmG3HT+ta/iGCF4uEoihjvhIKEU2e46yZzHWZKiQXCq5wBET849wh/d X-Received: by 2002:a17:906:1197:: with SMTP id n23mr3471328eja.359.1609952023927; Wed, 06 Jan 2021 08:53:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609952023; cv=none; d=google.com; s=arc-20160816; b=dCfhIG3MT6eMKnSwbLZ7UMZwO/7YvHw9yqRRRXtq5Lzk9ejAB40ja/P2oR7WX51Bh+ QgnC3ehd5tKI5CT1jfjrxSqplAxM++5Ugr46jwa5vBZ5tNDjRhTO3zzkk30GLwYwcWw5 251knga3QNpYyqpBPFPJlY8KJvGSDnIk66RKeuf5duKfjKrPfqHykpc+kAgMSGuxgYxk euPGPO+lsSZBh2a0G67n572DDRKmIVbCQ2UD7OltqYtOzmqEcyUcDG/+zf4STXHbIFIh xgwA3WtAJUTTtaJzw0bgjseNgDWTjDn9RYB7OaTLlt81K/uXMFd6FesoGo5d1yUUGqor 0Jgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=z2z+L6eC/HD3E3MIfkhKTN9M4oc6Iae7izsI9Bx0EGM=; b=dh/MchuesZvHwPUvcVCD1h//RMXjuTBYifcajtXe2lMjpbna+BFVwftlhd8gzOS/GB wOzXeJx0bZh0EcSzDXAhdCtJFD5yDrflRBozmfkJASfJ/WZkOZA5NWdNbRKwOnD+btRW gwacsHfjJvrDyx8gBK4A7z0SUKfGXP/BIlEgzoVgWtapso8p3csWM1L3kV2LxvXGxMsv CzBwy555iniXLCcvwGwAi0iSRfW4y2OjSfVus+qfQQqzheK4SyCJy7mnZkcHXvCZpZzd h0sNXnuZwz6lfp9NnyUKBiLkx5gCUJJXjDJTXWStMtwSVQDhrN9fl+4I35MRZVTXzt7p s+qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=M7J09Cso; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h17si1103307ejd.473.2021.01.06.08.53.20; Wed, 06 Jan 2021 08:53:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=M7J09Cso; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727628AbhAFQwi (ORCPT + 99 others); Wed, 6 Jan 2021 11:52:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:55634 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727514AbhAFQwi (ORCPT ); Wed, 6 Jan 2021 11:52:38 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3A12023135; Wed, 6 Jan 2021 16:51:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609951917; bh=IMFq1KTGJiGS26sa9cl/BORdVmQ9PX8XxqpL5Ht486M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=M7J09CsoIrOgg2W3ZZhl1Sm3PPOgai/rGTDRZuCP8FaiFkPMRjqOeoNypbZhwFbDa hthH8l1PrJjZd5d0qjsprIUUFZDHPaE/NP6b7B4nZiNq+7CltAz/Fb6rRBvDyWb4Oe OUOC1gZWitEDjvHLLaMMCeN+/9aIxslmxVrBHbQM= Date: Wed, 6 Jan 2021 17:53:19 +0100 From: Greg KH To: Tudor.Ambarus@microchip.com Cc: pavel@ucw.cz, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org, dan.j.williams@intel.com, vkoul@kernel.org, Ludovic.Desroches@microchip.com, stable@vger.kernel.org Subject: Re: [PATCH 4.19] dmaengine: at_hdmac: Fix memory leak Message-ID: References: <20200920082838.GA813@amd> <80065eac-7dce-aadf-51ef-9a290973b9ec@microchip.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 05, 2021 at 08:03:20AM +0000, Tudor.Ambarus@microchip.com wrote: > On 1/4/21 1:02 PM, Greg KH wrote: > > EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe > > > > On Wed, Sep 23, 2020 at 08:19:18AM +0000, Tudor.Ambarus@microchip.com wrote: > >> On 9/23/20 11:13 AM, Tudor.Ambarus@microchip.com wrote: > >>> Hi, Pavel, > >>> > >>> On 9/20/20 11:28 AM, Pavel Machek wrote: > >>>> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe > >>>> > >>>> This fixes memory leak in at_hdmac. Mainline does not have the same > >>>> problem. > >>>> > >>>> Signed-off-by: Pavel Machek (CIP) > >>>> > >>>> diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c > >>>> index 86427f6ba78c..0847b2055857 100644 > >>>> --- a/drivers/dma/at_hdmac.c > >>>> +++ b/drivers/dma/at_hdmac.c > >>>> @@ -1714,8 +1714,10 @@ static struct dma_chan *at_dma_xlate(struct of_phandle_args *dma_spec, > >>>> atslave->dma_dev = &dmac_pdev->dev; > >>>> > >>>> chan = dma_request_channel(mask, at_dma_filter, atslave); > >>>> - if (!chan) > >>>> + if (!chan) { > >>>> + kfree(atslave); > >>>> return NULL; > >>>> + } > >>> > >>> Thanks for submitting this to stable. While the fix is good, you can instead > >>> cherry-pick the commit that hit upstream. In order to do that cleanly on top > >>> of v4.19.145, you have to pick two other fixes: > >>> > >>> commit a6e7f19c9100 ("dmaengine: at_hdmac: Substitute kzalloc with kmalloc") > >>> commit 3832b78b3ec2 ("dmaengine: at_hdmac: add missing put_device() call in at_dma_xlate()")>>> commit a6e7f19c9100 ("dmaengine: at_hdmac: Substitute kzalloc with kmalloc") > >> > >> this last commit should have been > >> commit e097eb7473d9 ("dmaengine: at_hdmac: add missing kfree() call in at_dma_xlate()") > >> > >> bad copy and paste :) > > > > So are all 3 of those needed on both 5.4.y and 4.19.y to resolve this > > issue? > > > > Yes. I've just cherry-picked all three commits on both v5.4.86 and v4.19.164, > everything looks ok. I also compiled using sama5_defconfig, all good. > > The order in which they should be taken is 1/ a6e7f19c9100, then 2/ 3832b78b3ec2, > and 3/ e097eb7473d9. Thanks, will go queue those up now. greg k-h