Skip to content

Commit

Permalink
ceph: plug leak of incoming message during connection fault/close
Browse files Browse the repository at this point in the history
If we explicitly close a connection, or there is a socket error, we need
to drop any partially received message.

Signed-off-by: Sage Weil <sage@newdream.net>
  • Loading branch information
Sage Weil committed Dec 22, 2009
1 parent 9ec7cab commit cf3e5c4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions fs/ceph/messenger.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,11 @@ static void reset_connection(struct ceph_connection *con)
ceph_msg_remove_list(&con->out_queue);
ceph_msg_remove_list(&con->out_sent);

if (con->in_msg) {
ceph_msg_put(con->in_msg);
con->in_msg = NULL;
}

con->connect_seq = 0;
con->out_seq = 0;
if (con->out_msg) {
Expand Down Expand Up @@ -1288,7 +1293,7 @@ static int read_partial_message(struct ceph_connection *con)
con->in_msg = con->ops->alloc_msg(con, &con->in_hdr);
if (!con->in_msg) {
/* skip this message */
dout("alloc_msg returned NULL, skipping message\n");
pr_err("alloc_msg returned NULL, skipping message\n");
con->in_base_pos = -front_len - middle_len - data_len -
sizeof(m->footer);
con->in_tag = CEPH_MSGR_TAG_READY;
Expand Down Expand Up @@ -1327,7 +1332,7 @@ static int read_partial_message(struct ceph_connection *con)
if (con->ops->alloc_middle)
ret = con->ops->alloc_middle(con, m);
if (ret < 0) {
dout("alloc_middle failed, skipping payload\n");
pr_err("alloc_middle fail skipping payload\n");
con->in_base_pos = -middle_len - data_len
- sizeof(m->footer);
ceph_msg_put(con->in_msg);
Expand Down Expand Up @@ -1498,6 +1503,7 @@ static int try_write(struct ceph_connection *con)
set_bit(CONNECTING, &con->state);
clear_bit(NEGOTIATING, &con->state);

BUG_ON(con->in_msg);
con->in_tag = CEPH_MSGR_TAG_READY;
dout("try_write initiating connect on %p new state %lu\n",
con, con->state);
Expand Down

0 comments on commit cf3e5c4

Please sign in to comment.