[Drbd-dev] drbd: rcu_read_lock() and rcu_dereference() for tconn->net_conf
Philipp Reisner
philipp.reisner at linbit.com
Fri Nov 16 13:00:47 CET 2012
Am Montag, 12. November 2012, 22:06:59 schrieb Dan Carpenter:
> Hello Philipp Reisner,
>
> This is a semi-automatic email about new static checker warnings.
>
> The patch 44ed167da748: "drbd: rcu_read_lock() and rcu_dereference()
> for tconn->net_conf" from Apr 19, 2011, leads to the following Smatch
> complaint:
>
> drivers/block/drbd/drbd_state.c:566 is_valid_state()
> error: we previously assumed 'nc' could be null (see line 525)
>
> drivers/block/drbd/drbd_state.c
> 524 nc = rcu_dereference(mdev->tconn->net_conf);
> 525 if (nc) {
> ^^
> New check.
>
> 526 if (!nc->two_primaries && ns.role == R_PRIMARY) {
> 527 if (ns.peer == R_PRIMARY)
[...]
> 565 else if ((ns.conn == C_VERIFY_S || ns.conn == C_VERIFY_T) &&
> 566 (nc->verify_alg[0] == 0))
> ^^^^^^^^^^^^^^
> New dereference.
> Probably a false positive, but it's not immediately obvious what's going
> on. Maybe add a comment?
>
For developers familiar with the DRBD code it is obvious that if an online
verify may start (ns.conn == C_VERIFY_S || ns.conn == C_VERIFY_T) we have
an established connection, and that implies that nc is not NULL.
So, yes, it is a false positive.
Best,
Phil
More information about the drbd-dev
mailing list