From nobody Mon Apr 6 00:09:57 2026 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 A3A20ECAAA1 for ; Tue, 13 Sep 2022 03:00:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229906AbiIMDAR (ORCPT ); Mon, 12 Sep 2022 23:00:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230119AbiIMDAJ (ORCPT ); Mon, 12 Sep 2022 23:00:09 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10CBB140A9 for ; Mon, 12 Sep 2022 20:00:06 -0700 (PDT) Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MRSlm56VHzmVGh; Tue, 13 Sep 2022 10:56:20 +0800 (CST) Received: from dggpemm500007.china.huawei.com (7.185.36.183) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 13 Sep 2022 11:00:04 +0800 Received: from huawei.com (10.175.103.91) by dggpemm500007.china.huawei.com (7.185.36.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 13 Sep 2022 11:00:03 +0800 From: Yang Yingliang To: CC: Subject: [PATCH -next v2] habanalabs/gaudi2: fix free irq in error path in gaudi2_enable_msix() Date: Tue, 13 Sep 2022 11:07:14 +0800 Message-ID: <20220913030714.974259-1-yangyingliang@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.103.91] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm500007.china.huawei.com (7.185.36.183) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add two variables to store completion irq and event queue irq. And add a new lable to free event queue irq in error path in gaudi2_enable_msix(). Fixes: d7bb1ac89b2f ("habanalabs: add gaudi2 asic-specific code") Signed-off-by: Yang Yingliang --- v2: print correct irq in error prints. --- drivers/misc/habanalabs/gaudi2/gaudi2.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/misc/habanalabs/gaudi2/gaudi2.c b/drivers/misc/habanal= abs/gaudi2/gaudi2.c index 98336a1a84b0..8f521d8a1aa1 100644 --- a/drivers/misc/habanalabs/gaudi2/gaudi2.c +++ b/drivers/misc/habanalabs/gaudi2/gaudi2.c @@ -3518,6 +3518,7 @@ static int gaudi2_enable_msix(struct hl_device *hdev) struct asic_fixed_properties *prop =3D &hdev->asic_prop; struct gaudi2_device *gaudi2 =3D hdev->asic_specific; int rc, irq, i, j, user_irq_init_cnt; + int completion_irq, event_queue_irq; irq_handler_t irq_handler; struct hl_cq *cq; =20 @@ -3532,26 +3533,28 @@ static int gaudi2_enable_msix(struct hl_device *hde= v) return rc; } =20 - irq =3D pci_irq_vector(hdev->pdev, GAUDI2_IRQ_NUM_COMPLETION); + completion_irq =3D pci_irq_vector(hdev->pdev, GAUDI2_IRQ_NUM_COMPLETION); cq =3D &hdev->completion_queue[GAUDI2_RESERVED_CQ_CS_COMPLETION]; - rc =3D request_irq(irq, hl_irq_handler_cq, 0, gaudi2_irq_name(GAUDI2_IRQ_= NUM_COMPLETION), cq); + rc =3D request_irq(completion_irq, hl_irq_handler_cq, 0, + gaudi2_irq_name(GAUDI2_IRQ_NUM_COMPLETION), cq); if (rc) { - dev_err(hdev->dev, "Failed to request IRQ %d", irq); + dev_err(hdev->dev, "Failed to request IRQ %d", completion_irq); goto free_irq_vectors; } =20 - irq =3D pci_irq_vector(hdev->pdev, GAUDI2_IRQ_NUM_EVENT_QUEUE); - rc =3D request_irq(irq, hl_irq_handler_eq, 0, gaudi2_irq_name(GAUDI2_IRQ_= NUM_EVENT_QUEUE), - &hdev->event_queue); + event_queue_irq =3D pci_irq_vector(hdev->pdev, GAUDI2_IRQ_NUM_EVENT_QUEUE= ); + rc =3D request_irq(event_queue_irq, hl_irq_handler_eq, 0, + gaudi2_irq_name(GAUDI2_IRQ_NUM_EVENT_QUEUE), + &hdev->event_queue); if (rc) { - dev_err(hdev->dev, "Failed to request IRQ %d", irq); + dev_err(hdev->dev, "Failed to request IRQ %d", event_queue_irq); goto free_completion_irq; } =20 rc =3D gaudi2_dec_enable_msix(hdev); if (rc) { dev_err(hdev->dev, "Failed to enable decoder IRQ"); - goto free_completion_irq; + goto free_event_queue_irq; } =20 for (i =3D GAUDI2_IRQ_NUM_USER_FIRST, j =3D prop->user_dec_intr_count, us= er_irq_init_cnt =3D 0; @@ -3582,9 +3585,11 @@ static int gaudi2_enable_msix(struct hl_device *hdev) =20 gaudi2_dec_disable_msix(hdev, GAUDI2_IRQ_NUM_SHARED_DEC1_ABNRM + 1); =20 +free_event_queue_irq: + free_irq(event_queue_irq, &hdev->event_queue); + free_completion_irq: - irq =3D pci_irq_vector(hdev->pdev, GAUDI2_IRQ_NUM_COMPLETION); - free_irq(irq, cq); + free_irq(completion_irq, cq); =20 free_irq_vectors: pci_free_irq_vectors(hdev->pdev); --=20 2.25.1