Patch "can: m_can: pci: add missing m_can_class_free_dev() in probe/remove methods" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    can: m_can: pci: add missing m_can_class_free_dev() in probe/remove methods

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     can-m_can-pci-add-missing-m_can_class_free_dev-in-pr.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 4e047a0c44ecc8ca5472bf4b708a4f1f2e63754c
Author: Zhang Changzhong <zhangchangzhong@xxxxxxxxxx>
Date:   Fri Nov 11 20:11:23 2022 +0800

    can: m_can: pci: add missing m_can_class_free_dev() in probe/remove methods
    
    [ Upstream commit 1eca1d4cc21b6d0fc5f9a390339804c0afce9439 ]
    
    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 <zhangchangzhong@xxxxxxxxxx>
    Reviewed-by: Jarkko Nikula <jarkko.nikula@xxxxxxxxxxxxxxx>
    Link: https://lore.kernel.org/all/1668168684-6390-1-git-send-email-zhangchangzhong@xxxxxxxxxx
    Signed-off-by: Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/can/m_can/m_can_pci.c b/drivers/net/can/m_can/m_can_pci.c
index 8f184a852a0a..f2219aa2824b 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);
 }
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux