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); From patchwork Wed Aug 22 14:24:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 10572979 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 C7F8D13B6 for ; Wed, 22 Aug 2018 14:25:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B621C28F64 for ; Wed, 22 Aug 2018 14:25:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A9E4129436; Wed, 22 Aug 2018 14:25:13 +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 50EF728F64 for ; Wed, 22 Aug 2018 14:25:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728718AbeHVRuS (ORCPT ); Wed, 22 Aug 2018 13:50:18 -0400 Received: from mout.gmx.net ([212.227.17.21]:41251 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728057AbeHVRuS (ORCPT ); Wed, 22 Aug 2018 13:50:18 -0400 Received: from localhost.localdomain ([116.30.194.189]) by mail.gmx.com (mrgmx101 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MIzGn-1fq1EG1qsj-002Z56; Wed, 22 Aug 2018 16:25:07 +0200 From: Chengguang Xu To: ceph-devel@vger.kernel.org Cc: zyan@redhat.com, idryomov@gmail.com, Chengguang Xu Subject: [PATCH 2/2] libceph: add error handling code for osd_req_op_xattr_init() Date: Wed, 22 Aug 2018 22:24:38 +0800 Message-Id: <20180822142438.31632-2-cgxu519@gmx.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180822142438.31632-1-cgxu519@gmx.com> References: <20180822142438.31632-1-cgxu519@gmx.com> X-Provags-ID: V03:K1:Trebw4+eWYOeKAzilofD/IrcbeD0cyWTSLQr+sySo6+4p29UYvq rdMKndinHPeqcocLBgaxUVvkHL3Zoei+bfGeAhfGR+FzzINwP647C9i6WGX/Ouv7XYkPaCk oubI6H9EtP1BbruMD9fGqg0yOpzvB/CVcqLu1nnd8RqDtjF2gDFW3KxgXNJDuBZfXwKBIfH 0Y/KV1CWfcgLOBs2bYzjw== X-UI-Out-Filterresults: notjunk:1;V01:K0:faelVjKkp2g=:5eS2uD3bJ5ofgs1m7C65YW INLKJCAMN5wHjGsGD9ApfRyiI4DWYn5rWAT4o7FBIAydDL1MUmtyBSRU6X1rX28CQNRv9tuAr ASd7jNIIcv53h1HMnX5VxDBGlEyUiid5t8/73EFWmgemq1cWauHOqHvkZHSurDRzrvxaoxQnK 216Rf6V1h+S77wm9tEaoDrO00r/b992HcaZ7XsrBEAlVeJq23sb6KjkYSw4MgLCcih0hmHMET gO53mWBd5eMqa0DPYMa5iSuzisS7IfEYJ8TJ4MXKj6mVTn55lnnOodnBaF2jmTdLkc2TmifwD Vygz3eMtinHtPRInWL3WBghYR5Rwe7C6FbG73zSlnQ5gxdplksHuSvibFq3kGxJI5jEScoEGP 4mF3KEau+5BacHPo58lN1naSMPP8Oo5cYX9yNpVeBFuCgqulii+XnYSzseGrwul6G35ExRkEH BAKl6LT8ilJKdTxdr657bQaPVVS42ml/UxCQ6gABqhoM0CpmOaSGopS9v6W12V749CptVwrqE yNhDaJUXogQ8RM7Y93YxKue33JkW4qTozMXPIGtHqtab0NBwGAjwmaQ/3wl+1upG+Vcb3CrLq ahO0mpgvploDyS2vJTmuhuMRI4a/A9jRtQY8xCixsqtekXWbVsiDsEh1pGRjVouHVRPFR8DGd s0HKWG6ut8QzH7QMMnl01JupXbolSsD/XkPRoj0aogcotcc/uWK8w+bqNKXkgquR/WNooHtlM m5viK4Q9GxoZKoZGVeYfPlTSKRHIUD8tiO0VLdvG3NclGTnjdepcurJ1+cY= 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_xattr_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 2a84bd39b3ba..89bf2f3fbdbf 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c @@ -821,6 +821,7 @@ int osd_req_op_xattr_init(struct ceph_osd_request *osd_req, unsigned int which, opcode, 0); struct ceph_pagelist *pagelist; size_t payload_len; + int err; BUG_ON(opcode != CEPH_OSD_OP_SETXATTR && opcode != CEPH_OSD_OP_CMPXATTR); @@ -832,10 +833,14 @@ int osd_req_op_xattr_init(struct ceph_osd_request *osd_req, unsigned int which, payload_len = strlen(name); op->xattr.name_len = payload_len; - ceph_pagelist_append(pagelist, name, payload_len); + err = ceph_pagelist_append(pagelist, name, payload_len); + if (err < 0) + goto out_free; op->xattr.value_len = size; - ceph_pagelist_append(pagelist, value, size); + err = ceph_pagelist_append(pagelist, value, size); + if (err < 0) + goto out_free; payload_len += size; op->xattr.cmp_op = cmp_op; @@ -844,6 +849,10 @@ int osd_req_op_xattr_init(struct ceph_osd_request *osd_req, unsigned int which, ceph_osd_data_pagelist_init(&op->xattr.osd_data, pagelist); op->indata_len = payload_len; return 0; + +out_free: + ceph_pagelist_release(pagelist); + return err; } EXPORT_SYMBOL(osd_req_op_xattr_init);