From patchwork Wed Aug 22 14:24:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 10572977 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5F006112E for ; Wed, 22 Aug 2018 14:25:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F20028FA7 for ; Wed, 22 Aug 2018 14:25:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41476294BF; Wed, 22 Aug 2018 14:25:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D342828FA7 for ; Wed, 22 Aug 2018 14:25:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728518AbeHVRuN (ORCPT ); Wed, 22 Aug 2018 13:50:13 -0400 Received: from mout.gmx.net ([212.227.17.22]:36559 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728057AbeHVRuM (ORCPT ); Wed, 22 Aug 2018 13:50:12 -0400 Received: from localhost.localdomain ([116.30.194.189]) by mail.gmx.com (mrgmx101 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MHLNn-1ffVUW2kpn-00E8qw; Wed, 22 Aug 2018 16:25:00 +0200 From: Chengguang Xu To: ceph-devel@vger.kernel.org Cc: zyan@redhat.com, idryomov@gmail.com, Chengguang Xu Subject: [PATCH 1/2] libceph: add error handling code for osd_req_op_cls_init() Date: Wed, 22 Aug 2018 22:24:37 +0800 Message-Id: <20180822142438.31632-1-cgxu519@gmx.com> X-Mailer: git-send-email 2.17.1 X-Provags-ID: V03:K1:FRj9PXhTbxKEbpAzvv55g8mBlq72hyX1uw4P0EMBlynnMbYxGqV qHdInxTR6/oZL0vFcGPBKsKd7rjtuI750rOiaphuw2u2hG2TXK7b98FHQmPOFlX4FXeLzlK wypGkDlkfKgr1VtTcpOTLg4q7yM769ZkkdSjJt8ZjhJXWbyMKXHuid/d0G8mgo305iZbk/H FCOAngc4NagxxLfUAhAKQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:QHk+O2puUaE=:P1Hb3e3PWUWHQnM6rxbNcB ubbOhbxfb4gusD99Fw81ORB0oi4MkJacaUyihx915jJBjUFcOksOm/s7OEkHR+wlXX7vlDLRz EmANIW5FRL5yyniMUgjkux+uHpezscLPPQBT7eM5EdyV1uZ2WEWc9iVD28KOkmPV9G6T+oCu9 1t2pepix0gqLkHSuF2IvsZsvMUZe2l/8OAKM457YReQoeEDdLsKplU9o9KTmQGKw/eyZD4EGW 0+IhWqhSTgXzdpyLF/MiK0l7xwakrv67cNKl3kFTW0YKAAD4ttTZGWrfLWN4KTD3suB3zPqDR pJTWb2c6FAy0dB49eAYEBcIIcyf6a+D8ZJRJMk8+GldNFC74l9FFGI5ylPCl3wMo6TiQYRQ2t 4M6ik3rd+uYFpWiAsoH83Lq04wKqlHl24E6x8/mUtJB9D8gGF2lJfNEEHenWQTLkiQmAwMxtO nm779IAA1MgNVJwnb3QZBIrgwlWyBJNVuZJGSJTorvOOd2MJFVwD2NITte4PN7wEExYsANcAK 5JSNU8O5/0jUlq5ew3vaGKxDZW6zTZLUPUoBEE67HY+eDwI7xj4tatAWK8oZ/jPYMwcpcW8Q7 su545iZ2PVh+gwPZbr3wMTbewhyTsobRt3vyX7xc4OoG/4ddVgkCTAQYpICYCs89RG+BY7YsP CmeH2nsvQt7uYrzGmPfUTS5qvJXa1U3TYLgiF7Gvq2eP5sbQTwOna7u7KiGVMvPQUta+SssIb 08INbrfeqX1RzWXm9+zxNMHeoXMn5/a7XTsd6AAi/NmYJjA8PWrhXhLSb0M= Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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);