Skip to content

Commit

Permalink
cnic: Prevent "scheduling while atomic" when calling ->cnic_init()
Browse files Browse the repository at this point in the history
cnic_dev_list is protected by rtnl_lock and cnic_dev_lock spin_lock during
modifications.  When looping on cnic_dev_list and calling ->cnic_init(),
we should just hold rtnl_lock since ->cnic_init() may sleep.

Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Michael Chan authored and David S. Miller committed Dec 23, 2010
1 parent 9b09336 commit 8adc924
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/net/cnic.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ MODULE_DESCRIPTION("Broadcom NetXtreme II CNIC Driver");
MODULE_LICENSE("GPL");
MODULE_VERSION(CNIC_MODULE_VERSION);

/* cnic_dev_list modifications are protected by both rtnl and cnic_dev_lock */
static LIST_HEAD(cnic_dev_list);
static LIST_HEAD(cnic_udev_list);
static DEFINE_RWLOCK(cnic_dev_lock);
Expand Down Expand Up @@ -445,14 +446,12 @@ int cnic_register_driver(int ulp_type, struct cnic_ulp_ops *ulp_ops)

/* Prevent race conditions with netdev_event */
rtnl_lock();
read_lock(&cnic_dev_lock);
list_for_each_entry(dev, &cnic_dev_list, list) {
struct cnic_local *cp = dev->cnic_priv;

if (!test_and_set_bit(ULP_F_INIT, &cp->ulp_flags[ulp_type]))
ulp_ops->cnic_init(dev);
}
read_unlock(&cnic_dev_lock);
rtnl_unlock();

return 0;
Expand Down

0 comments on commit 8adc924

Please sign in to comment.