[PATCH 1/2] libceph: add error handling code for osd_req_op_cls_init()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Without reservation, ceph_pagelist_append() may fail with error -ENOMEM,
so catch the error in osd_req_op_cls_init() to avoid unexpected behavior.

Signed-off-by: Chengguang Xu <cgxu519@xxxxxxx>
---
 net/ceph/osd_client.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 60934bd8796c..2a84bd39b3ba 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -774,6 +774,7 @@ int osd_req_op_cls_init(struct ceph_osd_request *osd_req, unsigned int which,
 	struct ceph_pagelist *pagelist;
 	size_t payload_len = 0;
 	size_t size;
+	int err;
 
 	BUG_ON(opcode != CEPH_OSD_OP_CALL);
 
@@ -787,20 +788,28 @@ int osd_req_op_cls_init(struct ceph_osd_request *osd_req, unsigned int which,
 	size = strlen(class);
 	BUG_ON(size > (size_t) U8_MAX);
 	op->cls.class_len = size;
-	ceph_pagelist_append(pagelist, class, size);
+	err = ceph_pagelist_append(pagelist, class, size);
+	if (err < 0)
+		goto out_free;
 	payload_len += size;
 
 	op->cls.method_name = method;
 	size = strlen(method);
 	BUG_ON(size > (size_t) U8_MAX);
 	op->cls.method_len = size;
-	ceph_pagelist_append(pagelist, method, size);
+	err = ceph_pagelist_append(pagelist, method, size);
+	if (err < 0)
+		goto out_free;
 	payload_len += size;
 
 	osd_req_op_cls_request_info_pagelist(osd_req, which, pagelist);
 
 	op->indata_len = payload_len;
 	return 0;
+
+out_free:
+	ceph_pagelist_release(pagelist);
+	return err;
 }
 EXPORT_SYMBOL(osd_req_op_cls_init);
 
-- 
2.17.1




[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux