Skip to content

Commit

Permalink
ceph: fix null pointer dereference in discard_cap_releases()
Browse files Browse the repository at this point in the history
send_mds_reconnect() may call discard_cap_releases() after all
release messages have been dropped by cleanup_cap_releases()

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
Reviewed-by: Sage Weil <sage@inktank.com>
  • Loading branch information
Yan, Zheng authored and Sage Weil committed Apr 5, 2014
1 parent d90deda commit 00bd8ed
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions fs/ceph/mds_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1462,15 +1462,18 @@ static void discard_cap_releases(struct ceph_mds_client *mdsc,

dout("discard_cap_releases mds%d\n", session->s_mds);

/* zero out the in-progress message */
msg = list_first_entry(&session->s_cap_releases,
struct ceph_msg, list_head);
head = msg->front.iov_base;
num = le32_to_cpu(head->num);
dout("discard_cap_releases mds%d %p %u\n", session->s_mds, msg, num);
head->num = cpu_to_le32(0);
msg->front.iov_len = sizeof(*head);
session->s_num_cap_releases += num;
if (!list_empty(&session->s_cap_releases)) {
/* zero out the in-progress message */
msg = list_first_entry(&session->s_cap_releases,
struct ceph_msg, list_head);
head = msg->front.iov_base;
num = le32_to_cpu(head->num);
dout("discard_cap_releases mds%d %p %u\n",
session->s_mds, msg, num);
head->num = cpu_to_le32(0);
msg->front.iov_len = sizeof(*head);
session->s_num_cap_releases += num;
}

/* requeue completed messages */
while (!list_empty(&session->s_cap_releases_done)) {
Expand Down

0 comments on commit 00bd8ed

Please sign in to comment.