Skip to content

Commit

Permalink
drbd: Fix rcu_read_lock balance on error path
Browse files Browse the repository at this point in the history
Signed-off-by: Andreas Gruenbacher <[email protected]>
Signed-off-by: Philipp Reisner <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
andreas-gruenbacher authored and axboe committed Jun 28, 2013
1 parent 6110d70 commit f9eb7bf
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions drivers/block/drbd/drbd_nl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2658,7 +2658,6 @@ int nla_put_status_info(struct sk_buff *skb, struct drbd_conf *mdev,
const struct sib_info *sib)
{
struct state_info *si = NULL; /* for sizeof(si->member); */
struct net_conf *nc;
struct nlattr *nla;
int got_ldev;
int err = 0;
Expand Down Expand Up @@ -2688,13 +2687,19 @@ int nla_put_status_info(struct sk_buff *skb, struct drbd_conf *mdev,
goto nla_put_failure;

rcu_read_lock();
if (got_ldev)
if (disk_conf_to_skb(skb, rcu_dereference(mdev->ldev->disk_conf), exclude_sensitive))
goto nla_put_failure;
if (got_ldev) {
struct disk_conf *disk_conf;

nc = rcu_dereference(mdev->tconn->net_conf);
if (nc)
err = net_conf_to_skb(skb, nc, exclude_sensitive);
disk_conf = rcu_dereference(mdev->ldev->disk_conf);
err = disk_conf_to_skb(skb, disk_conf, exclude_sensitive);
}
if (!err) {
struct net_conf *nc;

nc = rcu_dereference(mdev->tconn->net_conf);
if (nc)
err = net_conf_to_skb(skb, nc, exclude_sensitive);
}
rcu_read_unlock();
if (err)
goto nla_put_failure;
Expand Down

0 comments on commit f9eb7bf

Please sign in to comment.