File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -4604,23 +4604,27 @@ static bool blk_mq_elv_switch_none(struct list_head *head,
4604
4604
{
4605
4605
struct blk_mq_qe_pair * qe ;
4606
4606
4607
- if (!q -> elevator )
4608
- return true;
4609
-
4610
4607
qe = kmalloc (sizeof (* qe ), GFP_NOIO | __GFP_NOWARN | __GFP_NORETRY );
4611
4608
if (!qe )
4612
4609
return false;
4613
4610
4614
4611
/* q->elevator needs protection from ->sysfs_lock */
4615
4612
mutex_lock (& q -> sysfs_lock );
4616
4613
4614
+ /* the check has to be done with holding sysfs_lock */
4615
+ if (!q -> elevator ) {
4616
+ kfree (qe );
4617
+ goto unlock ;
4618
+ }
4619
+
4617
4620
INIT_LIST_HEAD (& qe -> node );
4618
4621
qe -> q = q ;
4619
4622
qe -> type = q -> elevator -> type ;
4620
4623
/* keep a reference to the elevator module as we'll switch back */
4621
4624
__elevator_get (qe -> type );
4622
4625
list_add (& qe -> node , head );
4623
4626
elevator_disable (q );
4627
+ unlock :
4624
4628
mutex_unlock (& q -> sysfs_lock );
4625
4629
4626
4630
return true;
You can’t perform that action at this time.
0 commit comments