Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7246240c authored by Sage Weil's avatar Sage Weil Committed by Alex Elder
Browse files

libceph: avoid NULL kref_put from NULL alloc_msg return

The ceph_on_in_msg_alloc() method calls the ->alloc_msg() helper which
may return NULL.  It also drops con->mutex while it allocates a message,
which means that the connection state may change (e.g., get closed).  If
that happens, we clean up and bail out.  Avoid calling ceph_msg_put() on
a NULL return value and triggering a crash.

This was observed when an ->alloc_msg() call races with a timeout that
resends a zillion messages and resets the connection, and ->alloc_msg()
returns NULL (because the request was resent to another target).

Fixes http://tracker.newdream.net/issues/3342



Signed-off-by: default avatarSage Weil <sage@inktank.com>
Reviewed-by: default avatarAlex Elder <elder@inktank.com>
parent 0f9831a8
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -2742,6 +2742,7 @@ static int ceph_con_in_msg_alloc(struct ceph_connection *con, int *skip)
		msg = con->ops->alloc_msg(con, hdr, skip);
		mutex_lock(&con->mutex);
		if (con->state != CON_STATE_OPEN) {
			if (msg)
				ceph_msg_put(msg);
			return -EAGAIN;
		}