AW: net: m_can: missing mutexes in tx_work_queue and isr-handler

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

 



> Can you show us the patch?

My current patch currently just locks the isr and work queue.
I guess that additional locks are necessary too (e.g. in m_can_close)

Subject: [PATCH] can: m_can: added mutex to lock isr and tx work queue

---
 drivers/net/can/m_can/m_can.c | 17 ++++++++++++++++-
 drivers/net/can/m_can/m_can.h |  1 +
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 2395b1225cc8..34de6be2db76 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -1085,7 +1085,7 @@ static int m_can_echo_tx_event(struct net_device *dev)
 	return err;
 }
 
-static irqreturn_t m_can_isr(int irq, void *dev_id)
+static irqreturn_t m_can_isr2(int irq, void *dev_id)
 {
 	struct net_device *dev = (struct net_device *)dev_id;
 	struct m_can_classdev *cdev = netdev_priv(dev);
@@ -1150,6 +1150,17 @@ static irqreturn_t m_can_isr(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
+static irqreturn_t m_can_isr(int irq, void *dev_id)
+{
+	struct net_device *dev = (struct net_device *)dev_id;
+	struct m_can_classdev *cdev = netdev_priv(dev);
+	irqreturn_t ret;
+	mutex_lock(&cdev->lock);
+	ret = m_can_isr2(irq, dev_id);
+	mutex_unlock(&cdev->lock);
+	return ret;
+}
+
 static const struct can_bittiming_const m_can_bittiming_const_30X = {
 	.name = KBUILD_MODNAME,
 	.tseg1_min = 2,		/* Time segment 1 = prop_seg + phase_seg1 */
@@ -1771,7 +1782,9 @@ static void m_can_tx_work_queue(struct work_struct *ws)
 	struct m_can_classdev *cdev = container_of(ws, struct m_can_classdev,
 						   tx_work);
 
+	mutex_lock(&cdev->lock);
 	m_can_tx_handler(cdev);
+	mutex_unlock(&cdev->lock);
 }
 
 static netdev_tx_t m_can_start_xmit(struct sk_buff *skb,
@@ -1825,6 +1838,8 @@ static int m_can_open(struct net_device *dev)
 	struct m_can_classdev *cdev = netdev_priv(dev);
 	int err;
 
+	mutex_init(&cdev->lock);
+
 	err = phy_power_on(cdev->transceiver);
 	if (err)
 		return err;
diff --git a/drivers/net/can/m_can/m_can.h b/drivers/net/can/m_can/m_can.h
index 520e14277dff..9d7245108e60 100644
--- a/drivers/net/can/m_can/m_can.h
+++ b/drivers/net/can/m_can/m_can.h
@@ -91,6 +91,7 @@ struct m_can_classdev {
 
 	int pm_clock_support;
 	int is_peripheral;
+	struct mutex lock;
 
 	struct mram_cfg mcfg[MRAM_CFG_NUM];
 
-- 
2.34.1






[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux