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