drbd: rcu_read_lock() and rcu_dereference() for tconn->net_conf
A message that is not in the archive (sent off-list or not yet received): [email protected]
Philipp Reisner
maintainerAm Montag, 12. November 2012, 22:06:59 schrieb Dan Carpenter:
Quoted 19 lines
Hello Philipp Reisner,
This is a semi-automatic email about new static checker warnings.
The patch
44ed167da748: "drbd:rcu_read_lock()andrcu_dereference()fortconn->net_conf" from Apr 19, 2011, leads to the following Smatch complaint:
drivers/block/drbd/drbd_state.c:566is_valid_state()
error: we previously assumed 'nc' could be null (see line 525)
drivers/block/drbd/drbd_state.c524 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)
[...]
Quoted 7 lines
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