Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp1068417rdb; Sun, 7 Jan 2024 02:02:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IEM8KKVYdNQS+HoJGOsr+cf1IyECYyb6RuSW543kLwPC1PJCyFmvt9lrIFF1YCRDyTDrgbP X-Received: by 2002:a05:6808:f06:b0:3bd:26f4:95ad with SMTP id m6-20020a0568080f0600b003bd26f495admr1498460oiw.2.1704621760639; Sun, 07 Jan 2024 02:02:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704621760; cv=none; d=google.com; s=arc-20160816; b=Uhd4UzFiCg8BViZCDm34zrurFWi1gi2lN4Y5mPem+vo1NAOa9sYsW8E3m71D73ePO1 im7ut+m373zEN9BU34SubGMmz9u0nSXz4B78aNkotwbBEsPJWZhxszRm5lqcTijqEl8p hASa+AysYfGoTatiUukrifnwlPOdXDKyzCuF+FOy9svh6hkdHV6UXykwVXHQjFQY2qD3 z6SbUf1cZC1Fy/Y+5/E2AJTdzS2DfEPlWS2C1j8S6EwDFyj2xQXpDiNZroYZO+iMv2LW 0NrMmuej5srsZ/bEtwACSS5WnKHxxS5ATDX/h3OlialoruewpmP/SICw922rWr4fOALM yiKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=WHjXr8iYmZyxJWRVeVFfUIvl8ESYTgVff4hTRZ6j4QY=; fh=dNnfSg18Ptr+OweKY4QKN/WRiJyhS4OXToJzVPS7qUI=; b=Dbvs5q6Fblm747YcgVAJgVgtnYw2r9j/M89LDRa/wHnLXlRWUSP1u1uulx4JQxDwER 1uQdOSM8N6FcsxNmYsUFfAuKFFHdmih+0bclAkdmRTHG3QYHev+Lxe7GcclV5xNYg74H 2azzufkgpw6+C6j6n5MDcVVsLiYThx7puFPfUw+MYDtKV9BTDCEYuX+pwo5YoBFGFqsk CeNi4bQR+HINlIMj3ofEWxQjyhzdxxbyJyI3CgDTWbf1uDiWHywSdAcSmlNw5WcDJKjT jk8li6QDHTiPFV6tmJwUTUDDfGXBRig4KLITCXOtzE9HrBUAJuMRx9WR3tLelwSKlFXe Dkog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=kIySmNNe; spf=pass (google.com: domain of linux-kernel+bounces-18829-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18829-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id x126-20020a626384000000b006da28981d64si4338079pfb.149.2024.01.07.02.02.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jan 2024 02:02:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-18829-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=kIySmNNe; spf=pass (google.com: domain of linux-kernel+bounces-18829-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18829-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 8E387B218AF for ; Sun, 7 Jan 2024 10:02:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 528E312E71; Sun, 7 Jan 2024 10:02:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="kIySmNNe" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.smtpout.orange.fr (smtp-29.smtpout.orange.fr [80.12.242.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD97312E68 for ; Sun, 7 Jan 2024 10:02:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wanadoo.fr Received: from pop-os.home ([92.140.202.140]) by smtp.orange.fr with ESMTPA id MPysrRwtE9WXyMPz1rZ57p; Sun, 07 Jan 2024 11:02:19 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1704621739; bh=WHjXr8iYmZyxJWRVeVFfUIvl8ESYTgVff4hTRZ6j4QY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kIySmNNe2Zo+v+2ODdcfgIetNBd42jrc8kK0zax81Q2dAITnszJqtjcq5EbTR8Vp0 N6sEdpTJslfgaoDl45o2kiy2ZM8lsLvxMcH/Y04ZJ847XOSjSFOPo0wEkiHsZ2gFcC L3O13SXHpNrTETWVtm5OflWMaLGgxTte43+RnJaO2W/CwJNYP43LdDh06WqhwZnCvR Zu1kcbFcpmZOfvfvriKPytSpidAuJBcgeSpl2JF1dUnNXo3qE0gsh7UdKje0u8ETtf khAEqokUaK13K6Q3uAhL0SUcA07B8oPYEGearxk7NMRp64QJw0CAy6K6YF3Ie8902K jI2HE2bZgy6+g== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 07 Jan 2024 11:02:19 +0100 X-ME-IP: 92.140.202.140 From: Christophe JAILLET To: vkoul@kernel.org, jiaheng.fan@nxp.com, peng.ma@nxp.com, wen.he_1@nxp.com Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH 1/3] dmaengine: fsl-qdma: Fix a memory leak related to the status queue DMA Date: Sun, 7 Jan 2024 11:02:03 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This dma_alloc_coherent() is undone in the remove function, but not in the error handling path of fsl_qdma_probe(). Switch to the managed version to fix the issue in the probe and simplify the remove function. Fixes: b092529e0aa0 ("dmaengine: fsl-qdma: Add qDMA controller driver for Layerscape SoCs") Signed-off-by: Christophe JAILLET --- drivers/dma/fsl-qdma.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/drivers/dma/fsl-qdma.c b/drivers/dma/fsl-qdma.c index 47cb28468049..38409e06040a 100644 --- a/drivers/dma/fsl-qdma.c +++ b/drivers/dma/fsl-qdma.c @@ -563,11 +563,11 @@ static struct fsl_qdma_queue /* * Buffer for queue command */ - status_head->cq = dma_alloc_coherent(&pdev->dev, - sizeof(struct fsl_qdma_format) * - status_size, - &status_head->bus_addr, - GFP_KERNEL); + status_head->cq = dmam_alloc_coherent(&pdev->dev, + sizeof(struct fsl_qdma_format) * + status_size, + &status_head->bus_addr, + GFP_KERNEL); if (!status_head->cq) { devm_kfree(&pdev->dev, status_head); return NULL; @@ -1268,8 +1268,6 @@ static void fsl_qdma_cleanup_vchan(struct dma_device *dmadev) static void fsl_qdma_remove(struct platform_device *pdev) { - int i; - struct fsl_qdma_queue *status; struct device_node *np = pdev->dev.of_node; struct fsl_qdma_engine *fsl_qdma = platform_get_drvdata(pdev); @@ -1277,12 +1275,6 @@ static void fsl_qdma_remove(struct platform_device *pdev) fsl_qdma_cleanup_vchan(&fsl_qdma->dma_dev); of_dma_controller_free(np); dma_async_device_unregister(&fsl_qdma->dma_dev); - - for (i = 0; i < fsl_qdma->block_number; i++) { - status = fsl_qdma->status[i]; - dma_free_coherent(&pdev->dev, sizeof(struct fsl_qdma_format) * - status->n_cq, status->cq, status->bus_addr); - } } static const struct of_device_id fsl_qdma_dt_ids[] = { -- 2.34.1