File drbd-Fix-a-possible-NULL-deref-found-with-gcc-11-fan.patch of Package drbd.28199

From 494c67169d4a7ad38632dc322b5bb0a24f805279 Mon Sep 17 00:00:00 2001
From: Philipp Reisner <philipp.reisner@linbit.com>
Date: Mon, 28 Jun 2021 22:43:12 +0200
Subject: [PATCH] drbd: Fix a possible NULL deref (found with gcc-11 -fanalyze)

When we assume that have_no = true after assignment from
resource->twopc_reply.state_change_failed and that in the loop
failed_by does not get assigned, then we end with a NULL deref
a bit later.
---
 drbd/drbd_state.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drbd/drbd_state.c b/drbd/drbd_state.c
index aa9dc8c3..67b17211 100644
--- a/drbd/drbd_state.c
+++ b/drbd/drbd_state.c
@@ -4139,9 +4139,9 @@ static enum drbd_state_rv get_cluster_wide_reply(struct drbd_resource *resource,
 	else if (handshake_disconnect)
 		rv = SS_HANDSHAKE_DISCONNECT;
 	else if (have_no) {
-		if (context)
+		if (context && failed_by)
 			_drbd_state_err(context, "Declined by peer %s (id: %d), see the kernel log there",
-					rcu_dereference((failed_by)->transport.net_conf)->name,
+					rcu_dereference(failed_by->transport.net_conf)->name,
 					failed_by->peer_node_id);
 		rv = SS_CW_FAILED_BY_PEER;
 	}
-- 
2.16.4

openSUSE Build Service is sponsored by