Skip to content

Commit

Permalink
md/linear: rcu_dereference outside read-lock section
Browse files Browse the repository at this point in the history
According to the comment in linear_stop function
rcu_dereference in linear_start and linear_stop functions
occurs under reconfig_mutex. The patch represents this
agreement in code and prevents lockdep complaint.

Found by Linux Driver Verification project (linuxtesting.org)

Signed-off-by: Denis Efremov <yefremov.denis@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
  • Loading branch information
evdenis authored and neilbrown committed Oct 11, 2012
1 parent 02f3939 commit bc78c57
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions drivers/md/linear.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,9 @@ static int linear_add(struct mddev *mddev, struct md_rdev *rdev)
if (!newconf)
return -ENOMEM;

oldconf = rcu_dereference(mddev->private);
oldconf = rcu_dereference_protected(mddev->private,
lockdep_is_held(
&mddev->reconfig_mutex));
mddev->raid_disks++;
rcu_assign_pointer(mddev->private, newconf);
md_set_array_sectors(mddev, linear_size(mddev, 0, 0));
Expand All @@ -256,7 +258,10 @@ static int linear_add(struct mddev *mddev, struct md_rdev *rdev)

static int linear_stop (struct mddev *mddev)
{
struct linear_conf *conf = mddev->private;
struct linear_conf *conf =
rcu_dereference_protected(mddev->private,
lockdep_is_held(
&mddev->reconfig_mutex));

/*
* We do not require rcu protection here since
Expand Down

0 comments on commit bc78c57

Please sign in to comment.