File tree 1 file changed +13
-7
lines changed 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -3676,15 +3676,21 @@ static void pwq_unbound_release_workfn(struct work_struct *work)
3676
3676
unbound_release_work );
3677
3677
struct workqueue_struct * wq = pwq -> wq ;
3678
3678
struct worker_pool * pool = pwq -> pool ;
3679
- bool is_last ;
3679
+ bool is_last = false ;
3680
3680
3681
- if (WARN_ON_ONCE (!(wq -> flags & WQ_UNBOUND )))
3682
- return ;
3681
+ /*
3682
+ * when @pwq is not linked, it doesn't hold any reference to the
3683
+ * @wq, and @wq is invalid to access.
3684
+ */
3685
+ if (!list_empty (& pwq -> pwqs_node )) {
3686
+ if (WARN_ON_ONCE (!(wq -> flags & WQ_UNBOUND )))
3687
+ return ;
3683
3688
3684
- mutex_lock (& wq -> mutex );
3685
- list_del_rcu (& pwq -> pwqs_node );
3686
- is_last = list_empty (& wq -> pwqs );
3687
- mutex_unlock (& wq -> mutex );
3689
+ mutex_lock (& wq -> mutex );
3690
+ list_del_rcu (& pwq -> pwqs_node );
3691
+ is_last = list_empty (& wq -> pwqs );
3692
+ mutex_unlock (& wq -> mutex );
3693
+ }
3688
3694
3689
3695
mutex_lock (& wq_pool_mutex );
3690
3696
put_unbound_pool (pool );
You can’t perform that action at this time.
0 commit comments