From 46bc7ff0091af95735c03995be7d6002b03944dd Mon Sep 17 00:00:00 2001
From: Chris Leech <cleech@redhat.com>
Date: Mon, 17 Nov 2014 21:34:06 -0800
Subject: [PATCH] guard against NULL ptr during discovery from unexpected event
When demand loading drivers during discovery, iscsiadm can receive an
unexpected netlink event, like a link up, when looking for a discovery
session login status. That could expose krecv_conn_state to a
connection without a valid recv_context pointer.
Guard against that to prevent the NULL dereference.
Signed-off-by: Chris Leech <cleech@redhat.com>
---
usr/netlink.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/usr/netlink.c b/usr/netlink.c
index 1c4b5cc..18be5e5 100644
--- a/usr/netlink.c
+++ b/usr/netlink.c
@@ -1035,6 +1035,10 @@ static int krecv_conn_state(struct iscsi_conn *conn, uint32_t *state)
/* fatal handling error or conn error */
goto exit;
+ /* unexpected event without a receive context */
+ if (!conn->recv_context)
+ return -EAGAIN;
+
*state = *(enum iscsi_conn_state *)conn->recv_context->data;
ipc_ev_clbk->put_ev_context(conn->recv_context);
--
1.9.3