From patchwork Fri Nov 11 12:11:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Changzhong X-Patchwork-Id: 18705 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp694184wru; Fri, 11 Nov 2022 03:54:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf4b6iNVuwEN29LrZyMePI/1VY3x872NYjgvFjGUo+TuXMCPe6sa7KReNo9+Mh22LeRSEsPH X-Received: by 2002:a17:903:26d2:b0:186:9ecf:94f3 with SMTP id jg18-20020a17090326d200b001869ecf94f3mr2213505plb.105.1668167689266; Fri, 11 Nov 2022 03:54:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668167689; cv=none; d=google.com; s=arc-20160816; b=gbaduoAV5tYeE9Pf186fkiFdPlUKsM56cWeGSi8OU5HqoatJQGMBj0upBH2FuzjW1J pFD3FeaB9HoCP4qUw/wNPvl+3euc93ZMbRPwW8NmKUctBTcP2TBUZTpxJ/S1A51h3Aqg MX/nTcIVElWIHbxjSKKKpihFdSBH4X3Ia44yQ03EZ/VvE2wiJbynxXD5U4OjshEYYPeO 5weqRTfwjOKXug3+Gr1Exp8jk/0Ci0Uwl4H6DKHCZHYwmNjvAtwly0ddiSy2iWDb+M01 UeJbxBNu9SOSCj++Oq04Pmq9rCMncBQ2X04uhlyJxid9ml5m21QdszHhC+h7SIp/xHbq hscA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n24-20020a63a518000000b004701d95bd0csi2150095pgf.431.2022.11.11.03.54.36; Fri, 11 Nov 2022 03:54:49 -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 + 99 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749200603241033505?= X-GMAIL-MSGID: =?utf-8?q?1749200603241033505?= 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 Reviewed-by: Jarkko Nikula --- 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); }