Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1653791 > unrolled thread

[PATCH] enic: Fix another sleep-in-atomic bug

Started byJia-Ju Bai <baijiaju1990@163.com>
First post2017-05-31 04:50 +0200
Last post2017-05-31 20:40 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] enic: Fix another sleep-in-atomic bug Jia-Ju Bai <baijiaju1990@163.com> - 2017-05-31 04:50 +0200
    Re: [PATCH] enic: Fix another sleep-in-atomic bug David Miller <davem@davemloft.net> - 2017-05-31 20:40 +0200

#1653791 — [PATCH] enic: Fix another sleep-in-atomic bug

FromJia-Ju Bai <baijiaju1990@163.com>
Date2017-05-31 04:50 +0200
Subject[PATCH] enic: Fix another sleep-in-atomic bug
Message-ID<tN1RT-7cZ-1@gated-at.bofh.it>
The driver may sleep under a spin lock in some function call paths.
The 1st function call path is:
enic_tx_hang_reset (acquire the lock by spin_lock)
  enic_stop
    enic_synchronize_irqs
      synchronize_irq --> may sleep
The 2nd function call path is:
enic_tx_hang_reset (acquire the lock by spin_lock)
  enic_dev_wait
    schedule_timeout_uninterruptible --> may sleep
The 3rd function call path is:
enic_tx_hang_reset (acquire the lock by spin_lock)
  enic_open
    enic_request_intr
      enic_set_rx_cpu_rmap
        enic_free_rx_cpu_rmap
          free_irq_cpu_rmap --> may sleep

To fix it, the "spin_lock" and "spin_unlock" are removed 
in enic_tx_hang_reset.

Signed-off-by: Jia-Ju Bai <baijiaju1990@163.com>
---
 drivers/net/ethernet/cisco/enic/enic_main.c |    2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
index 4b87bee..d6523e2 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -2330,7 +2330,6 @@ static void enic_tx_hang_reset(struct work_struct *work)
 
 	rtnl_lock();
 
-	spin_lock(&enic->enic_api_lock);
 	enic_dev_hang_notify(enic);
 	enic_stop(enic->netdev);
 	enic_dev_hang_reset(enic);
@@ -2339,7 +2338,6 @@ static void enic_tx_hang_reset(struct work_struct *work)
 	enic_set_rss_nic_cfg(enic);
 	enic_dev_set_ig_vlan_rewrite_mode(enic);
 	enic_open(enic->netdev);
-	spin_unlock(&enic->enic_api_lock);
 	call_netdevice_notifiers(NETDEV_REBOOT, enic->netdev);
 
 	rtnl_unlock();
-- 
1.7.9.5

[toc] | [next] | [standalone]


#1654539

FromDavid Miller <davem@davemloft.net>
Date2017-05-31 20:40 +0200
Message-ID<tNgHf-8pT-17@gated-at.bofh.it>
In reply to#1653791
From: Jia-Ju Bai <baijiaju1990@163.com>
Date: Wed, 31 May 2017 10:43:40 +0800

> The driver may sleep under a spin lock in some function call paths.
> The 1st function call path is:
> enic_tx_hang_reset (acquire the lock by spin_lock)
>   enic_stop
>     enic_synchronize_irqs
>       synchronize_irq --> may sleep
> The 2nd function call path is:
> enic_tx_hang_reset (acquire the lock by spin_lock)
>   enic_dev_wait
>     schedule_timeout_uninterruptible --> may sleep
> The 3rd function call path is:
> enic_tx_hang_reset (acquire the lock by spin_lock)
>   enic_open
>     enic_request_intr
>       enic_set_rx_cpu_rmap
>         enic_free_rx_cpu_rmap
>           free_irq_cpu_rmap --> may sleep
> 
> To fix it, the "spin_lock" and "spin_unlock" are removed 
> in enic_tx_hang_reset.
> 
> Signed-off-by: Jia-Ju Bai <baijiaju1990@163.com>

Likewise, you can't just blindly remove locks to fix a warning like
this.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web