Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2022380rwb; Fri, 11 Nov 2022 04:04:34 -0800 (PST) X-Google-Smtp-Source: AA0mqf6bvM15iVt8erLZeGYT62Sv7j4I/PeRO2yH+GhQax2G8BNth7nLoaT+vQpRv60t6wqjH6pe X-Received: by 2002:a05:6402:515c:b0:461:b1b9:bed0 with SMTP id n28-20020a056402515c00b00461b1b9bed0mr1210341edd.122.1668168274178; Fri, 11 Nov 2022 04:04:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668168274; cv=none; d=google.com; s=arc-20160816; b=tcyJlM6oYI6ZzuB9UGWBfil/Q741fvEhByoixy6jhVHgcQ1uVXFaz1Av9GpFJ+2Mmu XOxDxCwQ7qi7+5Rh5oWrRcW3QcGvX7/tEslpxbbvL3sCtLHboDNKGWdLVTv+PVfeZazz g7bA+DNVrtGh4kDFwU+hfxUcMeWpz2tkDyKIQK12Z4dwIlH+uWdiVuRungp1rxWS+pUj +fa8ZfaRVccFJYe0CS7cKpulTOFfLGo4+KFCJcbOnrw4kxBmVwL25P8Fflc1tdSeZDE5 BS04eHnGCwaJlpcsjgh1F2J8jyON1o8NMA58c9WzPYnp1u/mOyq/G/9dQONuVbLKsMdU 9vzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=OiUsZVZGQtqmH2/eZbFrfMzTorfMPaDGaHPRq6fYuuQ=; b=TLAkB2ZzXcJXQ3QZOml9AtSioqFSNFCY1UICnZmxL5qXPzf84GB1gbx9wnnDBalhW3 4rjdnDlDVeKBERmgNy3aticl+TMgDiqQHVNCOvEbnqWe0RYeojoTTbxKr+F/OhAJeaOi OJm4H4oAaAQhxUZCOgQ0AubXzsZ/MsRT7nu8KdpFDFSLkjCRztH4h9hJRtE/bzif3yEc D6qRgYil3uED6glD5aW1jFDSRLqYRdjvVYjaaEWZNqO64Mj3z6O4qePhes6Yy9zvv7qp wyCOhTqYruRWV0C5oVwfUveq8LD+oGVDYC91YD/0xQOScAsehYLJbQYbfKKQnFQ+NV0h cRog== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id go32-20020a1709070da000b007ae2299a195si2107936ejc.815.2022.11.11.04.04.08; Fri, 11 Nov 2022 04:04:34 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233498AbiKKLvL (ORCPT + 92 others); Fri, 11 Nov 2022 06:51:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233436AbiKKLvF (ORCPT ); Fri, 11 Nov 2022 06:51:05 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C249327910; Fri, 11 Nov 2022 03:51:04 -0800 (PST) Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4N7xq058SFzHvcV; Fri, 11 Nov 2022 19:50:36 +0800 (CST) Received: from dggpeml500006.china.huawei.com (7.185.36.76) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 11 Nov 2022 19:51:03 +0800 Received: from localhost.localdomain (10.175.112.70) by dggpeml500006.china.huawei.com (7.185.36.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 11 Nov 2022 19:51:02 +0800 From: Zhang Changzhong To: Wolfgang Grandegger , Marc Kleine-Budde , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Raymond Tan , "Felipe Balbi (Intel)" , Jarkko Nikula CC: Zhang Changzhong , , , Subject: [PATCH 3/3] can: m_can: pci: add missing m_can_class_free_dev() in probe/remove methods Date: Fri, 11 Nov 2022 20:11:23 +0800 Message-ID: <1668168684-6390-1-git-send-email-zhangchangzhong@huawei.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.112.70] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpeml500006.china.huawei.com (7.185.36.76) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,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 In m_can_pci_remove() and error handling path of m_can_pci_probe(), m_can_class_free_dev() should be called to free resource allocated by m_can_class_allocate_dev(), otherwise there will be memleak. Fixes: cab7ffc0324f ("can: m_can: add PCI glue driver for Intel Elkhart Lake") Signed-off-by: Zhang Changzhong --- drivers/net/can/m_can/m_can_pci.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/can/m_can/m_can_pci.c b/drivers/net/can/m_can/m_can_pci.c index 8f184a8..f2219aa 100644 --- a/drivers/net/can/m_can/m_can_pci.c +++ b/drivers/net/can/m_can/m_can_pci.c @@ -120,7 +120,7 @@ static int m_can_pci_probe(struct pci_dev *pci, const struct pci_device_id *id) ret = pci_alloc_irq_vectors(pci, 1, 1, PCI_IRQ_ALL_TYPES); if (ret < 0) - return ret; + goto err_free_dev; mcan_class->dev = &pci->dev; mcan_class->net->irq = pci_irq_vector(pci, 0); @@ -132,7 +132,7 @@ static int m_can_pci_probe(struct pci_dev *pci, const struct pci_device_id *id) ret = m_can_class_register(mcan_class); if (ret) - goto err; + goto err_free_irq; /* Enable interrupt control at CAN wrapper IP */ writel(0x1, base + CTL_CSR_INT_CTL_OFFSET); @@ -144,8 +144,10 @@ static int m_can_pci_probe(struct pci_dev *pci, const struct pci_device_id *id) return 0; -err: +err_free_irq: pci_free_irq_vectors(pci); +err_free_dev: + m_can_class_free_dev(mcan_class->net); return ret; } @@ -161,6 +163,7 @@ static void m_can_pci_remove(struct pci_dev *pci) writel(0x0, priv->base + CTL_CSR_INT_CTL_OFFSET); m_can_class_unregister(mcan_class); + m_can_class_free_dev(mcan_class->net); pci_free_irq_vectors(pci); } -- 2.9.5