@@ -479,6 +479,7 @@ static int ioctx_add_table(struct kioctx *ctx, struct mm_struct *mm)
479
479
struct aio_ring * ring ;
480
480
481
481
spin_lock (& mm -> ioctx_lock );
482
+ rcu_read_lock ();
482
483
table = rcu_dereference (mm -> ioctx_table );
483
484
484
485
while (1 ) {
@@ -487,6 +488,7 @@ static int ioctx_add_table(struct kioctx *ctx, struct mm_struct *mm)
487
488
if (!table -> table [i ]) {
488
489
ctx -> id = i ;
489
490
table -> table [i ] = ctx ;
491
+ rcu_read_unlock ();
490
492
spin_unlock (& mm -> ioctx_lock );
491
493
492
494
ring = kmap_atomic (ctx -> ring_pages [0 ]);
@@ -497,6 +499,7 @@ static int ioctx_add_table(struct kioctx *ctx, struct mm_struct *mm)
497
499
498
500
new_nr = (table ? table -> nr : 1 ) * 4 ;
499
501
502
+ rcu_read_unlock ();
500
503
spin_unlock (& mm -> ioctx_lock );
501
504
502
505
table = kzalloc (sizeof (* table ) + sizeof (struct kioctx * ) *
@@ -507,6 +510,7 @@ static int ioctx_add_table(struct kioctx *ctx, struct mm_struct *mm)
507
510
table -> nr = new_nr ;
508
511
509
512
spin_lock (& mm -> ioctx_lock );
513
+ rcu_read_lock ();
510
514
old = rcu_dereference (mm -> ioctx_table );
511
515
512
516
if (!old ) {
@@ -631,10 +635,12 @@ static void kill_ioctx(struct mm_struct *mm, struct kioctx *ctx)
631
635
struct kioctx_table * table ;
632
636
633
637
spin_lock (& mm -> ioctx_lock );
638
+ rcu_read_lock ();
634
639
table = rcu_dereference (mm -> ioctx_table );
635
640
636
641
WARN_ON (ctx != table -> table [ctx -> id ]);
637
642
table -> table [ctx -> id ] = NULL ;
643
+ rcu_read_unlock ();
638
644
spin_unlock (& mm -> ioctx_lock );
639
645
640
646
/* percpu_ref_kill() will do the necessary call_rcu() */
0 commit comments