Skip to content

Commit a5e61b5

Browse files
Mikhail Lobanovaxboe
authored andcommitted
drbd: Add NULL check for net_conf to prevent dereference in state validation
If the net_conf pointer is NULL and the code attempts to access its fields without a check, it will lead to a null pointer dereference. Add a NULL check before dereferencing the pointer. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 44ed167 ("drbd: rcu_read_lock() and rcu_dereference() for tconn->net_conf") Cc: [email protected] Signed-off-by: Mikhail Lobanov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent acc8c0a commit a5e61b5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/block/drbd/drbd_state.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ is_valid_state(struct drbd_device *device, union drbd_state ns)
876876
ns.disk == D_OUTDATED)
877877
rv = SS_CONNECTED_OUTDATES;
878878

879-
else if ((ns.conn == C_VERIFY_S || ns.conn == C_VERIFY_T) &&
879+
else if (nc && (ns.conn == C_VERIFY_S || ns.conn == C_VERIFY_T) &&
880880
(nc->verify_alg[0] == 0))
881881
rv = SS_NO_VERIFY_ALG;
882882

0 commit comments

Comments
 (0)