Skip to contentSkip to conversation

libceph: fix ceph_msg_new error path

PATCH Applied Henry C Chang 3 participants 4 messages May 3, 2011 Ceph common code (libceph)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libceph: fix ceph_msg_new error path

If memory allocation failed, calling ceph_msg_put() will cause GPF since some of ceph_msg variables are not initialized first.

Fix Bug #970.

---
 net/ceph/messenger.c |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)
net/ceph/messenger.c +13 -13
index 05f3578..e15a82c 100644
@@ -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) {
@@ -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;
 
Signature · 1 line
1.7.2.3
Applied
#1 lore raw

Applied, thanks!

Quoted 63 lines · Henry C Chang

If memory allocation failed, calling ceph_msg_put() will cause GPF since some of ceph_msg variables are not initialized first.

Fix Bug #970.

---
 net/ceph/messenger.c |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)
net/ceph/messenger.c +13 -13
index 05f3578..e15a82c 100644
@@ -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) {
@@ -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;
 
Signature · 6 lines
1.7.2.3

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
In reply to Henry C Chang
Quoted 4 lines · Henry C Chang

If memory allocation failed, calling ceph_msg_put() will cause GPF since some of ceph_msg variables are not initialized first.

Fix Bug #970.

Looks good and explains the symptoms perfectly. Committed to ceph-client.git as 56f63aeb6360fb3ba9584bd5b094d55283a9e332. Thanks!

Signature · 1 line
:(){ :|:&};:
#3 lore raw
Quoted 9 lines · Tommi Virtanen
Quoted 4 lines · Henry C Chang

If memory allocation failed, calling ceph_msg_put() will cause GPF since some of ceph_msg variables are not initialized first.

Fix Bug #970.

Looks good and explains the symptoms perfectly. Committed to ceph-client.git as 56f63aeb6360fb3ba9584bd5b094d55283a9e332. Thanks!

I backed that out in favor of Sage's commits to for-linus. Sorry about the confusion.

Signature · 1 line
:(){ :|:&};: