Commit cdef59a9 authored by Tao Ma's avatar Tao Ma Committed by Mark Fasheh
Browse files

ocfs2: Fix NULL pointer dereferences in o2net



In some situations, ocfs2_set_nn_state might get called with sc = NULL and
valid = 0. If sc = NULL, we can't dereference it to get the o2nm_node
member. Instead, do what o2net_initialize_handshake does and use NULL when
calling o2net_reconnect_delay and o2net_idle_timeout.
Signed-off-by: default avatarTao Ma <tao.ma@oracle.com>
Signed-off-by: default avatarMark Fasheh <mark.fasheh@oracle.com>
parent c824c3c7
...@@ -451,9 +451,9 @@ static void o2net_set_nn_state(struct o2net_node *nn, ...@@ -451,9 +451,9 @@ static void o2net_set_nn_state(struct o2net_node *nn,
/* delay if we're withing a RECONNECT_DELAY of the /* delay if we're withing a RECONNECT_DELAY of the
* last attempt */ * last attempt */
delay = (nn->nn_last_connect_attempt + delay = (nn->nn_last_connect_attempt +
msecs_to_jiffies(o2net_reconnect_delay(sc->sc_node))) msecs_to_jiffies(o2net_reconnect_delay(NULL)))
- jiffies; - jiffies;
if (delay > msecs_to_jiffies(o2net_reconnect_delay(sc->sc_node))) if (delay > msecs_to_jiffies(o2net_reconnect_delay(NULL)))
delay = 0; delay = 0;
mlog(ML_CONN, "queueing conn attempt in %lu jiffies\n", delay); mlog(ML_CONN, "queueing conn attempt in %lu jiffies\n", delay);
queue_delayed_work(o2net_wq, &nn->nn_connect_work, delay); queue_delayed_work(o2net_wq, &nn->nn_connect_work, delay);
...@@ -1552,12 +1552,11 @@ static void o2net_connect_expired(struct work_struct *work) ...@@ -1552,12 +1552,11 @@ static void o2net_connect_expired(struct work_struct *work)
spin_lock(&nn->nn_lock); spin_lock(&nn->nn_lock);
if (!nn->nn_sc_valid) { if (!nn->nn_sc_valid) {
struct o2nm_node *node = nn->nn_sc->sc_node;
mlog(ML_ERROR, "no connection established with node %u after " mlog(ML_ERROR, "no connection established with node %u after "
"%u.%u seconds, giving up and returning errors.\n", "%u.%u seconds, giving up and returning errors.\n",
o2net_num_from_nn(nn), o2net_num_from_nn(nn),
o2net_idle_timeout(node) / 1000, o2net_idle_timeout(NULL) / 1000,
o2net_idle_timeout(node) % 1000); o2net_idle_timeout(NULL) % 1000);
o2net_set_nn_state(nn, NULL, 0, -ENOTCONN); o2net_set_nn_state(nn, NULL, 0, -ENOTCONN);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment