.. | .. |
---|
1131 | 1131 | /* remainder if it woke up early */ |
---|
1132 | 1132 | unsigned long jremain = 0; |
---|
1133 | 1133 | |
---|
| 1134 | + atomic_inc(&dev->refcnt); |
---|
| 1135 | + |
---|
1134 | 1136 | for (;;) { |
---|
1135 | 1137 | |
---|
1136 | 1138 | if (!jremain && dev->search_count) { |
---|
.. | .. |
---|
1158 | 1160 | */ |
---|
1159 | 1161 | mutex_unlock(&dev->list_mutex); |
---|
1160 | 1162 | |
---|
1161 | | - if (kthread_should_stop()) |
---|
| 1163 | + if (kthread_should_stop()) { |
---|
| 1164 | + __set_current_state(TASK_RUNNING); |
---|
1162 | 1165 | break; |
---|
| 1166 | + } |
---|
1163 | 1167 | |
---|
1164 | 1168 | /* Only sleep when the search is active. */ |
---|
1165 | 1169 | if (dev->search_count) { |
---|
.. | .. |
---|
1224 | 1228 | |
---|
1225 | 1229 | static void __exit w1_fini(void) |
---|
1226 | 1230 | { |
---|
1227 | | - struct w1_master *dev; |
---|
| 1231 | + struct w1_master *dev, *n; |
---|
1228 | 1232 | |
---|
1229 | 1233 | /* Set netlink removal messages and some cleanup */ |
---|
1230 | | - list_for_each_entry(dev, &w1_masters, w1_master_entry) |
---|
| 1234 | + list_for_each_entry_safe(dev, n, &w1_masters, w1_master_entry) |
---|
1231 | 1235 | __w1_remove_master_device(dev); |
---|
1232 | 1236 | |
---|
1233 | 1237 | w1_fini_netlink(); |
---|