Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp1255773rwb; Fri, 13 Jan 2023 09:46:10 -0800 (PST) X-Google-Smtp-Source: AMrXdXvMNQHWlKgSgUSgHEF5BJsdCG8B/iOpWV71ljQWLmBfEK5zWeZ77ipJl5TA229IlLXOfbap X-Received: by 2002:a62:b619:0:b0:574:3cde:385a with SMTP id j25-20020a62b619000000b005743cde385amr70526677pff.32.1673631970170; Fri, 13 Jan 2023 09:46:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673631970; cv=none; d=google.com; s=arc-20160816; b=v6CMPK/mh9V2T7WWUuhQeYTZCC79clWr48idVq1gP3fkfuMcgjBaoRrJ936oe9Or2k E2RZVO+NB2hKDhzTlQJld2/320wLVcpNlJnh4uN9kz3egGfeYxb3V+8oZddLRcq34zKR vHBDL4dU38JikNJPsQ+NBbNvZaTmWv+1C0oRT9QqkrrywijeVNdtpqKCET60PQ+0yflf vXC8BsGlMIV307PSOos7AFw6XuQPcFW7nVpOx28ufwWI+5evlsSuAVF5jHwR+Hb+kr7y j11hEOD9vTksxKfNZK8BIjwC4azs5OynYuQtNMKeUVbJILjJvmWdO8rLB3cnl2lPNhhF 1ctQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oKaK2sOF9l2wmzAkmDkVT4pB6CPlriRRtW6dod3JyPY=; b=UR/kGG5ej2LQCiM+YMlLIAAm0iUFe8SPXA3uKtYJIC3J8G4UuT+s1hrQSqLcjxPwJ6 OpkTgXNsq9OmKVPkwup6jAv+Y2zwLylfurkHJ8YXHGY2tFNxAkz5XN7o2IxijUvKzyL5 qg0vehuMMhrZdLo3abCRdHkJlHmRgCk7Pdr7VUKv7xU/JmyRWHTa0Ww8XjEctsH9CFoM ji4rwC6egD1giYoZ5x9xIsYuXTUkwqkfyvtY8QQ/1zdifCwdPtKu3H1gFWIc6c+J6A8c Mf/NL6M3MvyaFoMoWpw5xzUY9XmE4kpHdl4YP3gprezR1Ukf/WI3jMQHAwmgmuNQshAB ShXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baikalelectronics.ru header.s=post header.b=jAkT6QTM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=baikalelectronics.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c11-20020a056a000acb00b0058bc338c9b2si568473pfl.372.2023.01.13.09.46.03; Fri, 13 Jan 2023 09:46:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baikalelectronics.ru header.s=post header.b=jAkT6QTM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=baikalelectronics.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230324AbjAMRXJ (ORCPT + 51 others); Fri, 13 Jan 2023 12:23:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230126AbjAMRWH (ORCPT ); Fri, 13 Jan 2023 12:22:07 -0500 Received: from post.baikalelectronics.com (post.baikalelectronics.com [213.79.110.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1A56FA08A0; Fri, 13 Jan 2023 09:14:21 -0800 (PST) Received: from post.baikalelectronics.com (localhost.localdomain [127.0.0.1]) by post.baikalelectronics.com (Proxmox) with ESMTP id 36972E0F1D; Fri, 13 Jan 2023 20:14:20 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= baikalelectronics.ru; h=cc:cc:content-transfer-encoding :content-type:content-type:date:from:from:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=post; bh=oKaK2sOF9l2wmzAkmDkVT4pB6CPlriRRtW6dod3JyPY=; b=jAkT6QTMbq5K d9DxWgTkylINa8CEK40RCIs2m58R6oWFXWpZBWkYVyQZU8hY4i1FGGgB/Da8jsH/ vPVcW/1BlXRF2EqWWp/Bty60/pXTpDZ0sduhbhLmS/HKpQvAovzl+gQ1pjTECDtZ 4eEi5gZ7MgHnWMNWz+n8rysOyp6Ey3E= Received: from mail.baikal.int (mail.baikal.int [192.168.51.25]) by post.baikalelectronics.com (Proxmox) with ESMTP id 21703E0F13; Fri, 13 Jan 2023 20:14:20 +0300 (MSK) Received: from localhost (10.8.30.26) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 13 Jan 2023 20:14:19 +0300 From: Serge Semin To: Gustavo Pimentel , Vinod Koul , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Cai Huoqing , Robin Murphy , Jingoo Han , Frank Li , Manivannan Sadhasivam CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , caihuoqing , Yoshihiro Shimoda , , , , Gustavo Pimentel Subject: [PATCH v9 02/27] dmaengine: dw-edma: Release requested IRQs on failure Date: Fri, 13 Jan 2023 20:13:44 +0300 Message-ID: <20230113171409.30470-3-Sergey.Semin@baikalelectronics.ru> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230113171409.30470-1-Sergey.Semin@baikalelectronics.ru> References: <20230113171409.30470-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.8.30.26] X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From very beginning of the DW eDMA driver live in the kernel the method dw_edma_irq_request() hasn't been designed quite correct. In case if the request_irq() method fails to initialize the IRQ handler at some point the previously requested IRQs will be left initialized. It's prune to errors up to the system crash. Let's fix that by releasing the previously requested IRQs in the cleanup-on-error path of the dw_edma_irq_request() function. Fixes: e63d79d1ffcd ("dmaengine: Add Synopsys eDMA IP core driver") Signed-off-by: Serge Semin Reviewed-by: Manivannan Sadhasivam Tested-by: Manivannan Sadhasivam Acked-by: Vinod Koul --- Changelog v2: - This is a new patch added in v2 iteration of the series. --- drivers/dma/dw-edma/dw-edma-core.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/dma/dw-edma/dw-edma-core.c b/drivers/dma/dw-edma/dw-edma-core.c index c54b24ff5206..a8c1bd9c7ae9 100644 --- a/drivers/dma/dw-edma/dw-edma-core.c +++ b/drivers/dma/dw-edma/dw-edma-core.c @@ -893,10 +893,8 @@ static int dw_edma_irq_request(struct dw_edma *dw, dw_edma_interrupt_read, IRQF_SHARED, dw->name, &dw->irq[i]); - if (err) { - dw->nr_irqs = i; - return err; - } + if (err) + goto err_irq_free; if (irq_get_msi_desc(irq)) get_cached_msi_msg(irq, &dw->irq[i].msi); @@ -905,6 +903,14 @@ static int dw_edma_irq_request(struct dw_edma *dw, dw->nr_irqs = i; } + return 0; + +err_irq_free: + for (i--; i >= 0; i--) { + irq = chip->ops->irq_vector(dev, i); + free_irq(irq, &dw->irq[i]); + } + return err; } -- 2.39.0