From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FCC1C05027 for ; Fri, 20 Jan 2023 10:50:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229687AbjATKu2 (ORCPT ); Fri, 20 Jan 2023 05:50:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229574AbjATKu2 (ORCPT ); Fri, 20 Jan 2023 05:50:28 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A6C6B775; Fri, 20 Jan 2023 02:50:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1674211827; x=1705747827; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=HVxjOlrNxTX4w4hEmxDKY12/recHY5kWHUzbvS7si4c=; b=wfMMvOzJXucKqcH0vviLsZE6ylZZfsydaHfu1zT8Gg2bixdw6jTWBwKo t+zEfxqi63UakcvR1dtgn8FLHkvFBp0+U2jqIcw2VZBiriIsx4SnGzPZH kFG+eqz4bglDa8zUiRJUP1R5ER7XkYDz/2ugRZfK5tGQcsGrumjZnmPO5 UuJe5AOdxu440HV5JVI+9cTChgrh4uFhHe+8AhQ/w+uhReB920QzX+S2U Slsk7RaEI6/FimLgQhlWh3Jj/ZOzZfGVHDKo6lJjKH8EBLWGPBxORH6rI sKXKJoVYV4t6zHI7rZWnwHjtLwi8eAC90ODhSHjIfWkHmlt1FxOR/kIGW A==; X-IronPort-AV: E=Sophos;i="5.97,232,1669100400"; d="asc'?scan'208";a="196679949" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 20 Jan 2023 03:50:26 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Fri, 20 Jan 2023 03:50:25 -0700 Received: from wendy (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16 via Frontend Transport; Fri, 20 Jan 2023 03:50:24 -0700 Date: Fri, 20 Jan 2023 10:50:01 +0000 From: Conor Dooley To: shravan kumar CC: , , , , , , Subject: Re: [PATCH v1] dmaengine: sf-pdma: pdma_desc memory leak fix Message-ID: References: <20230120100623.3530634-1-shravan.chippa@microchip.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="OF1t+SvYHzumvf3V" Content-Disposition: inline In-Reply-To: <20230120100623.3530634-1-shravan.chippa@microchip.com> Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org --OF1t+SvYHzumvf3V Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hey Shravan, On Fri, Jan 20, 2023 at 03:36:23PM +0530, shravan kumar wrote: > From: Shravan Chippa >=20 > Commit b2cc5c465c2c ("dmaengine: sf-pdma: Add multithread support for a > DMA channel") changed sf_pdma_prep_dma_memcpy() to unconditionally > allocate a new sf_pdma_desc each time it is called. >=20 > The driver previously recycled descs, by checking the in_use flag, only > allocating additional descs if the existing one was in use. This logic > was removed in commit b2cc5c465c2c ("dmaengine: sf-pdma: Add multithread > support for a DMA channel"), but sf_pdma_free_desc() was not changed to > handle the new behaviour. >=20 > As a result, each time sf_pdma_prep_dma_memcpy() is called, the previous > descriptor is leaked, over time leading to memory starvation: >=20 > unreferenced object 0xffffffe008447300 (size 192): > comm "irq/39-mchp_dsc", pid 343, jiffies 4294906910 (age 981.200s) > hex dump (first 32 bytes): > 00 00 00 ff 00 00 00 00 b8 c1 00 00 00 00 00 00 ................ > 00 00 70 08 10 00 00 00 00 00 00 c0 00 00 00 00 ..p............. > backtrace: > [<00000000064a04f4>] kmemleak_alloc+0x1e/0x28 > [<00000000018927a7>] kmem_cache_alloc+0x11e/0x178 > [<000000002aea8d16>] sf_pdma_prep_dma_memcpy+0x40/0x112 >=20 > Add the missing kfree() to sf_pdma_free_desc(), and remove the redundant > in_use flag. >=20 > Fixes: b2cc5c465c2c ("dmaengine: sf-pdma: Add multithread support for a D= MA channel") > Signed-off-by: Shravan Chippa Reviewed-by: Conor Dooley Thanks, Conor. --OF1t+SvYHzumvf3V Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCY8pxygAKCRB4tDGHoIJi 0qXaAQDZziGG9P3c05/6Z1kseB+iYCmBwoVXkIs3fvUu4pMVbAEAuy3QU4BuPBtT yRzTBRue4wpLPBr8+CnJMHfbDl0n4wM= =S7BN -----END PGP SIGNATURE----- --OF1t+SvYHzumvf3V--