Skip to content

Commit

Permalink
libceph: fix ceph_msg_new error path
Browse files Browse the repository at this point in the history
If memory allocation failed, calling ceph_msg_put() will cause GPF
since some of ceph_msg variables are not initialized first.

Fix Bug torvalds#970.

Signed-off-by: Henry C Chang <[email protected]>
Signed-off-by: Sage Weil <[email protected]>
  • Loading branch information
henrycc authored and liewegas committed May 3, 2011
1 parent 3772d26 commit ca20892
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions net/ceph/messenger.c
Original file line number Diff line number Diff line change
Expand Up @@ -2267,6 +2267,19 @@ struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags)
m->more_to_follow = false;
m->pool = NULL;

/* middle */
m->middle = NULL;

/* data */
m->nr_pages = 0;
m->page_alignment = 0;
m->pages = NULL;
m->pagelist = NULL;
m->bio = NULL;
m->bio_iter = NULL;
m->bio_seg = 0;
m->trail = NULL;

/* front */
if (front_len) {
if (front_len > PAGE_CACHE_SIZE) {
Expand All @@ -2286,19 +2299,6 @@ struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags)
}
m->front.iov_len = front_len;

/* middle */
m->middle = NULL;

/* data */
m->nr_pages = 0;
m->page_alignment = 0;
m->pages = NULL;
m->pagelist = NULL;
m->bio = NULL;
m->bio_iter = NULL;
m->bio_seg = 0;
m->trail = NULL;

dout("ceph_msg_new %p front %d\n", m, front_len);
return m;

Expand Down

0 comments on commit ca20892

Please sign in to comment.