diff options
author | Sage Weil <sage@inktank.com> | 2012-10-25 11:49:41 -0400 |
---|---|---|
committer | Alex Elder <elder@inktank.com> | 2012-10-26 17:35:04 -0400 |
commit | 7246240c7c186542f73af4fadc744d66440f616f (patch) | |
tree | 2b6270df2edae0dcc6e7c7c3474ff9c46d841e55 /net | |
parent | 0f9831a89310cebba52d3f526e6cc5c2e403e6f1 (diff) |
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: Sage Weil <sage@inktank.com>
Reviewed-by: Alex Elder <elder@inktank.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/ceph/messenger.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index 66f6f56bcb23..1041114453db 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c | |||
@@ -2742,7 +2742,8 @@ static int ceph_con_in_msg_alloc(struct ceph_connection *con, int *skip) | |||
2742 | msg = con->ops->alloc_msg(con, hdr, skip); | 2742 | msg = con->ops->alloc_msg(con, hdr, skip); |
2743 | mutex_lock(&con->mutex); | 2743 | mutex_lock(&con->mutex); |
2744 | if (con->state != CON_STATE_OPEN) { | 2744 | if (con->state != CON_STATE_OPEN) { |
2745 | ceph_msg_put(msg); | 2745 | if (msg) |
2746 | ceph_msg_put(msg); | ||
2746 | return -EAGAIN; | 2747 | return -EAGAIN; |
2747 | } | 2748 | } |
2748 | con->in_msg = msg; | 2749 | con->in_msg = msg; |