From patchwork Sun Apr 9 14:26:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9671569 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6CD366020C for ; Sun, 9 Apr 2017 14:26:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 532C726E81 for ; Sun, 9 Apr 2017 14:26:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 446BB27F9A; Sun, 9 Apr 2017 14:26:59 +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=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 9087126E81 for ; Sun, 9 Apr 2017 14:26:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752320AbdDIO05 (ORCPT ); Sun, 9 Apr 2017 10:26:57 -0400 Received: from mout.web.de ([212.227.17.11]:57069 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752230AbdDIO0z (ORCPT ); Sun, 9 Apr 2017 10:26:55 -0400 Received: from [192.168.1.2] ([77.181.114.244]) by smtp.web.de (mrweb103 [213.165.67.124]) with ESMTPSA (Nemesis) id 0LnS8Q-1cQvza3SHe-00hhX0; Sun, 09 Apr 2017 16:26:41 +0200 Subject: [PATCH 2/3] iscsi-target: Delete error messages for failed memory allocations From: SF Markus Elfring To: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, Bart Van Assche , Hannes Reinecke , "Nicholas A. Bellinger" , Varun Prakash References: Cc: LKML , kernel-janitors@vger.kernel.org, Wolfram Sang Message-ID: Date: Sun, 9 Apr 2017 16:26:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-GB X-Provags-ID: V03:K0:Z8I1c1VgnYBezp/cdg3lZSatKfpxo+BfaB6+1CluzvpDXdWAIms +73JwaYeY6t+D+miEk9uFJiWUhYLSnzcWfiSuiHQEG1sBD2EC4Ur1jDQLvFQ53zEIU+3ukz 1O5ZYOIan/fF2WNveltUtYqrMkBz9S9rnH/CCVOb2r4PgvOBukE83Lai6Y5EY+HmGO6m/0Y 9hNMpoG8zMyhtAF/hBUYg== X-UI-Out-Filterresults: notjunk:1; V01:K0:CjvxAv/g0wg=:SJgkc582tBI+JRFUGcdnM6 g+lIwbxR2aCR3vVJVom0QZSWSrM6Ujl9nFMm0f4ff2ni91mH1KpUGbBwmivLDo+NHVtcpg3zY 0sFs5WDenLop0QbbcX1dil6QmuKaAe8edIQAa17pB3vlLpw2P8tbzvVWJAOQqjz+jA8/YczcY 0h759aNeUg+1h+ORD3nAGi0T6p7JwUomCflPBzwM9w2KSzEzEd3tC2RSC8+rYOZXQ20dQcnTO DZPx7rni9gZk8qfigQmlSe6ie5NzlSzFoq0VImEqGPXxPVMo32g0Uh/EoF2MEZOJdujWPM1ql ++MSpkdw14xVgEdABOHKG312xF1zfuP+ZHNLxeMI5DECXXpE0tMMJ+l7FfDfTxMq3xsGfh4WF oFzhEfiFM2lx/QVIGrAjeg9jdh1oPjhN8vn3kwOGRSTRtTpsGTg0YR1QZ8poFhBtgLxr/zN9j N7mFzEB9AZCXhBqBD+hutLKiUT8TXx47lkwiukjp3UsVFSJPRS4nzuogjD94WQzSxtiN5/H83 96RmaSPxm/Wgs1c8C6ZNDr5qUyoeRramy5BulPtXOFPXvdq33v1dyf5Z8vSyw0vtAgeQPfhSO 8E4ocSBkXmiHI7C+p8pDNyfxjfEf+wZdOv+diJKVP3BBE+ru0alqYQlC/f2oq2w7hyFAi9xqh KtY3AFjWhYpCSEpuXFysDklMJxXOyoizlBQcPbSCk9myuLpks5ShS9cehkxKURFyowkkGkSyo n6QfRA3tzUcxQZkJxTXm0wIjG7YyEFCGmuXutl7sp6xV4jM2IWXBrsKIt6jS+HHcyRh/zo2Td TdmQFoz Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sun, 9 Apr 2017 15:34:50 +0200 The script "checkpatch.pl" pointed information out like the following. WARNING: Possible unnecessary 'out of memory' message Thus remove such statements here. Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf Signed-off-by: Markus Elfring --- drivers/target/iscsi/iscsi_target.c | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 536b939afe9d..196e9dd138ca 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -129,10 +129,8 @@ struct iscsi_tiqn *iscsit_add_tiqn(unsigned char *buf) } tiqn = kzalloc(sizeof(struct iscsi_tiqn), GFP_KERNEL); - if (!tiqn) { - pr_err("Unable to allocate struct iscsi_tiqn\n"); + if (!tiqn) return ERR_PTR(-ENOMEM); - } sprintf(tiqn->tiqn, "%s", buf); INIT_LIST_HEAD(&tiqn->tiqn_list); @@ -364,7 +362,6 @@ struct iscsi_np *iscsit_add_np( np = kzalloc(sizeof(struct iscsi_np), GFP_KERNEL); if (!np) { - pr_err("Unable to allocate memory for struct iscsi_np\n"); mutex_unlock(&np_lock); return ERR_PTR(-ENOMEM); } @@ -699,10 +696,9 @@ static int __init iscsi_target_init_module(void) pr_debug("iSCSI-Target "ISCSIT_VERSION"\n"); iscsit_global = kzalloc(sizeof(struct iscsit_global), GFP_KERNEL); - if (!iscsit_global) { - pr_err("Unable to allocate memory for iscsit_global\n"); + if (!iscsit_global) return -1; - } + spin_lock_init(&iscsit_global->ts_bitmap_lock); mutex_init(&auth_id_lock); spin_lock_init(&sess_idr_lock); @@ -715,10 +711,8 @@ static int __init iscsi_target_init_module(void) size = BITS_TO_LONGS(ISCSIT_BITMAP_BITS) * sizeof(long); iscsit_global->ts_bitmap = vzalloc(size); - if (!iscsit_global->ts_bitmap) { - pr_err("Unable to allocate iscsit_global->ts_bitmap\n"); + if (!iscsit_global->ts_bitmap) goto configfs_out; - } lio_qr_cache = kmem_cache_create("lio_qr_cache", sizeof(struct iscsi_queue_req), @@ -986,10 +980,8 @@ static int iscsit_allocate_iovecs(struct iscsi_cmd *cmd) iov_count += ISCSI_IOV_DATA_BUFFER; cmd->iov_data = kcalloc(iov_count, sizeof(*cmd->iov_data), GFP_KERNEL); - if (!cmd->iov_data) { - pr_err("Unable to allocate cmd->iov_data\n"); + if (!cmd->iov_data) return -ENOMEM; - } cmd->orig_iov_data_count = iov_count; return 0; @@ -1850,8 +1842,6 @@ static int iscsit_handle_nop_out(struct iscsi_conn *conn, struct iscsi_cmd *cmd, ping_data = kzalloc(payload_length + 1, GFP_KERNEL); if (!ping_data) { - pr_err("Unable to allocate memory for" - " NOPOUT ping data.\n"); ret = -1; goto out; } @@ -1999,13 +1989,10 @@ iscsit_handle_task_mgt_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, cmd->data_direction = DMA_NONE; cmd->tmr_req = kzalloc(sizeof(struct iscsi_tmr_req), GFP_KERNEL); - if (!cmd->tmr_req) { - pr_err("Unable to allocate memory for" - " Task Management command!\n"); + if (!cmd->tmr_req) return iscsit_add_reject_cmd(cmd, ISCSI_REASON_BOOKMARK_NO_RESOURCES, buf); - } /* * TASK_REASSIGN for ERL=2 / connection stays inside of @@ -2265,11 +2252,9 @@ iscsit_handle_text_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, struct kvec iov[3]; text_in = kzalloc(payload_length, GFP_KERNEL); - if (!text_in) { - pr_err("Unable to allocate memory for" - " incoming text parameters\n"); + if (!text_in) goto reject; - } + cmd->text_in_ptr = text_in; memset(iov, 0, 3 * sizeof(struct kvec)); @@ -3353,11 +3338,9 @@ iscsit_build_sendtargets_response(struct iscsi_cmd *cmd, SENDTARGETS_BUF_LIMIT); payload = kzalloc(buffer_len, GFP_KERNEL); - if (!payload) { - pr_err("Unable to allocate memory for sendtargets" - " response.\n"); + if (!payload) return -ENOMEM; - } + /* * Locate pointer to iqn./eui. string for ICF_SENDTARGETS_SINGLE * explicit case..