[PATCH] can: m_can: initialize spin lock on device probe
From: Antonios Salios
Date: Thu Apr 24 2025 - 08:53:52 EST
The spin lock tx_handling_spinlock in struct m_can_classdev is not being
initialized. This leads to bug complaints from the kernel, eg. when
trying to send CAN frames with cansend from can-utils.
This patch fixes that by initializing the spin lock in the corresponding
device probe functions.
Signed-off-by: Antonios Salios <antonios@xxxxxx>
---
drivers/net/can/m_can/m_can_pci.c | 1 +
drivers/net/can/m_can/m_can_platform.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/drivers/net/can/m_can/m_can_pci.c b/drivers/net/can/m_can/m_can_pci.c
index 9ad7419f8..06243cd43 100644
--- a/drivers/net/can/m_can/m_can_pci.c
+++ b/drivers/net/can/m_can/m_can_pci.c
@@ -143,6 +143,7 @@ static int m_can_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
pm_runtime_use_autosuspend(dev);
pm_runtime_put_noidle(dev);
pm_runtime_allow(dev);
+ spin_lock_init(&mcan_class->tx_handling_spinlock);
return 0;
diff --git a/drivers/net/can/m_can/m_can_platform.c b/drivers/net/can/m_can/m_can_platform.c
index b832566ef..c09c61d25 100644
--- a/drivers/net/can/m_can/m_can_platform.c
+++ b/drivers/net/can/m_can/m_can_platform.c
@@ -154,6 +154,7 @@ static int m_can_plat_probe(struct platform_device *pdev)
ret = m_can_class_register(mcan_class);
if (ret)
goto out_runtime_disable;
+ spin_lock_init(&mcan_class->tx_handling_spinlock);
return ret;
--
2.49.0