Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp417041pxb; Tue, 1 Feb 2022 02:48:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJz771EDiNk2bErq1SZAOZyT4r9s6isXoukgbEY0U9bkZVrAzj6ZpNvHG2wPWr4EeVwpltvW X-Received: by 2002:aa7:c647:: with SMTP id z7mr24662357edr.55.1643712526684; Tue, 01 Feb 2022 02:48:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643712526; cv=none; d=google.com; s=arc-20160816; b=ZEq1ttgLS5Nhs2ha4tdVIYSCsw7beNKWXsLjGy6pfYGdPoPj+KItieNxCfN9HcgjDt 2zCSaAQTJUinVRS1AU5HKIaCMAu5drKlcWiezEQomxrWIKY4uUFPAJ7mUWUADSTDHnEQ lY7DzrYMB0WeLL7X0QwUCtcJq+aokDenu64wHsnkKNI8BeZc+iwyT5/F1ggWDq1YY+h7 ZKRvl1XqjGPkFlgqI7yZC4cMZSmPQ9jUUI7ZAcRRvHsZYtPR3EoXkaWBQNx0dhjvHFyW /n2H3/GNPTj2MrwimwBXLm/jAVAHydX/cCurPCCdUzrakE+R806f0EkRzuNdB7NBwDIb P+xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=y+4MIRUfz6hIElk7ondjp8/UZhk8H+sORHPuiIT/NXU=; b=Kn/EX34OSBUHca8iDwPS5ny88fG+oerjURjMIM4JWs83hQaGXX3qbSSWb2ioTFiyx6 GPT/fJFi6Kcc+GMu3v3z3Cg6Mbv3S3yBryV7ihv1ah0bkxIuEDH09Stfvsbg7tuhLa2l NohWLBgciNEplXz1puaF3/r5tqA2n/ru22SZJlSnF+dqfhWz3mU1/yF8xFDkjXoyU4la WfU1s4JajwaOtGfsqwNvMofdZUNgJbblJu2ubHfPgqfPYfh6XUGObyfbp1U6/FafzMEO e8a6ba5DLSMvpGPhtlcL+EssghyZwGBC3awceZ98lf2rCY6G7fcBgi8UqMJ/rpjyCBlg NVzg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b20si8866255edr.91.2022.02.01.02.48.21; Tue, 01 Feb 2022 02:48:46 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354962AbiA3OMU (ORCPT + 99 others); Sun, 30 Jan 2022 09:12:20 -0500 Received: from smtp10.smtpout.orange.fr ([80.12.242.132]:64671 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234830AbiA3OMS (ORCPT ); Sun, 30 Jan 2022 09:12:18 -0500 Received: from pop-os.home ([90.126.236.122]) by smtp.orange.fr with ESMTPA id EAwCnru7fEuQ2EAwCnR8Qu; Sun, 30 Jan 2022 15:12:17 +0100 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Sun, 30 Jan 2022 15:12:17 +0100 X-ME-IP: 90.126.236.122 From: Christophe JAILLET To: Sanjay R Mehta , Vinod Koul Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , dmaengine@vger.kernel.org Subject: [PATCH] dmaengine: ptdma: Fix the error handling path in pt_core_init() Date: Sun, 30 Jan 2022 15:12:09 +0100 Message-Id: <1b2573cf3cd077494531993239f80c08e7feb39e.1643551909.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to free resources correctly in the error handling path of pt_core_init(), 2 goto's have to be switched. Otherwise, some resources will leak and we will try to release things that have not been allocated yet. Fixes: fa5d823b16a9 ("dmaengine: ptdma: Initial driver for the AMD PTDMA") Signed-off-by: Christophe JAILLET --- drivers/dma/ptdma/ptdma-dev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/dma/ptdma/ptdma-dev.c b/drivers/dma/ptdma/ptdma-dev.c index 8a6bf291a73f..3fa2a6ed4b68 100644 --- a/drivers/dma/ptdma/ptdma-dev.c +++ b/drivers/dma/ptdma/ptdma-dev.c @@ -207,7 +207,7 @@ int pt_core_init(struct pt_device *pt) if (!cmd_q->qbase) { dev_err(dev, "unable to allocate command queue\n"); ret = -ENOMEM; - goto e_dma_alloc; + goto e_pool; } cmd_q->qidx = 0; @@ -230,7 +230,7 @@ int pt_core_init(struct pt_device *pt) /* Request an irq */ ret = request_irq(pt->pt_irq, pt_core_irq_handler, 0, dev_name(pt->dev), pt); if (ret) - goto e_pool; + goto e_dma_alloc; /* Update the device registers with queue information. */ cmd_q->qcontrol &= ~CMD_Q_SIZE; -- 2.32.0