From patchwork Tue Dec 12 21:52:04 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: 10108343 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 0E99F602C2 for ; Tue, 12 Dec 2017 21:53:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F3FEF27FA9 for ; Tue, 12 Dec 2017 21:53:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E8C47296BB; Tue, 12 Dec 2017 21:53: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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable 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 7334327FA9 for ; Tue, 12 Dec 2017 21:53:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752752AbdLLVw4 (ORCPT ); Tue, 12 Dec 2017 16:52:56 -0500 Received: from mout.web.de ([212.227.15.4]:61220 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752570AbdLLVwv (ORCPT ); Tue, 12 Dec 2017 16:52:51 -0500 Received: from [192.168.1.3] ([77.181.137.123]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0M0hsk-1fJZrF2cDW-00uq78; Tue, 12 Dec 2017 22:52:07 +0100 Subject: [PATCH 8/8] target/iscsi: Improve 16 size determinations From: SF Markus Elfring To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, Al Viro , Arun Easi , Bart Van Assche , Dan Carpenter , David Disseldorp , Hannes Reinecke , Ingo Molnar , "Jason A. Donenfeld" , Jiang Yi , Kees Cook , "Nicholas A. Bellinger" , Russell King , Tang Wenji , Theodore Ts'o , Varun Prakash Cc: LKML , kernel-janitors@vger.kernel.org References: <6163538d-a406-2f60-11a2-88b4694e9975@users.sourceforge.net> Message-ID: <5ec6d156-1b73-e0de-2c38-a8e3bc133e68@users.sourceforge.net> Date: Tue, 12 Dec 2017 22:52:04 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <6163538d-a406-2f60-11a2-88b4694e9975@users.sourceforge.net> Content-Language: en-GB X-Provags-ID: V03:K0:/zGTnu6+zP4s7wOyYlFsXW/cKCgyXVWGGRkJOMFNQTd6A2gTQUr b0z0iAKzpp+WnnjvhMA649O3jLp7dx1K0N5J4mg4okF9umykCQrFC7I/MSgo8Nml/rQAn4q unvthKJhV8qA1kUuOuSUbMZ+SsH8q3lQdFIzwJ/vCsUvh5FQkCAYvq0Kum3vHAPrSYidp8f PIPsMiY/+K5OfJ/CniPNw== X-UI-Out-Filterresults: notjunk:1; V01:K0:2apFb+58PS4=:/pNiGUhnJ83tLxDR8MWAL+ anhtA+daCp3Dk+cbS1DaZJ3BCn6Mf4CfXCsrp4iUzKrwh/Q957c66ss4ifx94sn7c/1bvu+xJ BwEsxP5/XyR8k38ZmhFuSIz3iwnVqTUfNgzRxd33oukJFiNFFCIo909RQjOHOAMjnfENieLBM zcEQO8WyaC/XpmpFiU5fZE/4F7K9NG6QZW1znTQdlIPSC+dhrmlQvHX5TJ9iC5EzXz9k0Qoyy B0fWsnO0+hgUvSlR3iTHWRsaHvrn4HOfUxHt7kd0iLd2kqQaQtiPxl2gA0/noH2SGDWcxXmL0 BgcdrjusYTxl6AXQ6b8yIQrObjpQdwQ6F7KUhbn5DKv30/hrqBKJIlnzLVwmBG3acudTF7E99 /64A6aII/TbQtoKSzBMsUfG6uwfe9I+dUijnXmC9SibUefoxnh/slKaYLDrgY4YFlgcFw2LqX LuWAsolthqwyKZOCCONIvlNjcUKdefu/+oY9NqPtDXzvSSWXwsswMhqpu8OEQTILa0DzOdB2x MRbE9GLMx/uNE3R2TbSh9joh+bdc6meEo2XE9g2r72xAqCgNy9oAu98nLZP+9rFPsTAUnR3r/ 40yr96uGm9oXWzNYWxKk0T5SyOyyMnN5Cn4zQSqQIHZrLrNU839dvsJ98Ej/GvgTQmlH7K/hC FMpnB/Y3+7l/IZWPzyq1Xde2UgBDSzKofv5Zegz+xsS0Bhx4tRPbz+gCSg2t5xQKyMMukEtx1 v8RgeSVrgmo9isxmYl0v5EEFCldkjD+Thm3uDD+lNf9C6+2hUDtN5H3ux+S/k1+Sty8PMzfbg lmfaffl6hOXXZejoC8XdFFCIc7kDD78sMv1H5lmIDGDRahyBJ8= 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: Tue, 12 Dec 2017 22:06:00 +0100 Replace the specification of data types by pointer dereferences as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/target/iscsi/iscsi_target_erl2.c | 2 +- drivers/target/iscsi/iscsi_target_login.c | 6 +++--- drivers/target/iscsi/iscsi_target_parameters.c | 10 +++++----- drivers/target/iscsi/iscsi_target_seq_pdu_list.c | 11 ++++++----- drivers/target/iscsi/iscsi_target_tpg.c | 4 ++-- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/drivers/target/iscsi/iscsi_target_erl2.c b/drivers/target/iscsi/iscsi_target_erl2.c index 87c27e8d4f49..80b8297f4b05 100644 --- a/drivers/target/iscsi/iscsi_target_erl2.c +++ b/drivers/target/iscsi/iscsi_target_erl2.c @@ -324,7 +324,7 @@ int iscsit_prepare_cmds_for_reallegiance(struct iscsi_conn *conn) * (struct iscsi_cmd->cr) so we need to allocate this before preparing the * connection's command list for connection recovery. */ - cr = kzalloc(sizeof(struct iscsi_conn_recovery), GFP_KERNEL); + cr = kzalloc(sizeof(*cr), GFP_KERNEL); if (!cr) return -1; diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c index cfaf564825e0..095651e48f36 100644 --- a/drivers/target/iscsi/iscsi_target_login.c +++ b/drivers/target/iscsi/iscsi_target_login.c @@ -46,7 +46,7 @@ static struct iscsi_login *iscsi_login_init_conn(struct iscsi_conn *conn) { struct iscsi_login *login; - login = kzalloc(sizeof(struct iscsi_login), GFP_KERNEL); + login = kzalloc(sizeof(*login), GFP_KERNEL); if (!login) return NULL; @@ -294,7 +294,7 @@ static int iscsi_login_zero_tsih_s1( struct iscsi_login_req *pdu = (struct iscsi_login_req *)buf; int ret; - sess = kzalloc(sizeof(struct iscsi_session), GFP_KERNEL); + sess = kzalloc(sizeof(*sess), GFP_KERNEL); if (!sess) { iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, ISCSI_LOGIN_STATUS_NO_RESOURCES); @@ -1244,7 +1244,7 @@ static int __iscsi_target_login_thread(struct iscsi_np *np) } spin_unlock_bh(&np->np_thread_lock); - conn = kzalloc(sizeof(struct iscsi_conn), GFP_KERNEL); + conn = kzalloc(sizeof(*conn), GFP_KERNEL); if (!conn) { /* Get another socket */ return 1; diff --git a/drivers/target/iscsi/iscsi_target_parameters.c b/drivers/target/iscsi/iscsi_target_parameters.c index a49b0b2a4f6c..110e81a0c97d 100644 --- a/drivers/target/iscsi/iscsi_target_parameters.c +++ b/drivers/target/iscsi/iscsi_target_parameters.c @@ -129,7 +129,7 @@ static struct iscsi_param *iscsi_set_default_param(struct iscsi_param_list *para { struct iscsi_param *param; - param = kzalloc(sizeof(struct iscsi_param), GFP_KERNEL); + param = kzalloc(sizeof(*param), GFP_KERNEL); if (!param) goto out; @@ -199,7 +199,7 @@ int iscsi_create_default_params(struct iscsi_param_list **param_list_ptr) struct iscsi_param *param; struct iscsi_param_list *pl; - pl = kzalloc(sizeof(struct iscsi_param_list), GFP_KERNEL); + pl = kzalloc(sizeof(*pl), GFP_KERNEL); if (!pl) return -ENOMEM; @@ -568,7 +568,7 @@ int iscsi_copy_param_list( struct iscsi_param *new_param = NULL; struct iscsi_param_list *param_list; - param_list = kzalloc(sizeof(struct iscsi_param_list), GFP_KERNEL); + param_list = kzalloc(sizeof(*param_list), GFP_KERNEL); if (!param_list) return -ENOMEM; @@ -583,7 +583,7 @@ int iscsi_copy_param_list( continue; } - new_param = kzalloc(sizeof(struct iscsi_param), GFP_KERNEL); + new_param = kzalloc(sizeof(*new_param), GFP_KERNEL); if (!new_param) goto err_out; @@ -714,7 +714,7 @@ static int iscsi_add_notunderstood_response( return -1; } - extra_response = kzalloc(sizeof(struct iscsi_extra_response), GFP_KERNEL); + extra_response = kzalloc(sizeof(*extra_response), GFP_KERNEL); if (!extra_response) return -ENOMEM; diff --git a/drivers/target/iscsi/iscsi_target_seq_pdu_list.c b/drivers/target/iscsi/iscsi_target_seq_pdu_list.c index 3a6e619bb30e..0fd914d92f4f 100644 --- a/drivers/target/iscsi/iscsi_target_seq_pdu_list.c +++ b/drivers/target/iscsi/iscsi_target_seq_pdu_list.c @@ -137,7 +137,8 @@ static int iscsit_randomize_pdu_lists( seq_count++; continue; } - array = kcalloc(seq_count, sizeof(u32), GFP_KERNEL); + + array = kcalloc(seq_count, sizeof(*array), GFP_KERNEL); if (!array) return -ENOMEM; @@ -155,7 +156,7 @@ static int iscsit_randomize_pdu_lists( } if (seq_count) { - array = kcalloc(seq_count, sizeof(u32), GFP_KERNEL); + array = kcalloc(seq_count, sizeof(*array), GFP_KERNEL); if (!array) return -ENOMEM; @@ -185,7 +186,7 @@ static int iscsit_randomize_seq_lists( if (!seq_count) return 0; - array = kcalloc(seq_count, sizeof(u32), GFP_KERNEL); + array = kcalloc(seq_count, sizeof(*array), GFP_KERNEL); if (!array) return -ENOMEM; @@ -538,7 +539,7 @@ int iscsit_build_pdu_and_seq_lists( iscsit_determine_counts_for_list(cmd, &bl, &seq_count, &pdu_count); if (!conn->sess->sess_ops->DataSequenceInOrder) { - seq = kcalloc(seq_count, sizeof(struct iscsi_seq), GFP_ATOMIC); + seq = kcalloc(seq_count, sizeof(*seq), GFP_ATOMIC); if (!seq) return -ENOMEM; @@ -547,7 +548,7 @@ int iscsit_build_pdu_and_seq_lists( } if (!conn->sess->sess_ops->DataPDUInOrder) { - pdu = kcalloc(pdu_count, sizeof(struct iscsi_pdu), GFP_ATOMIC); + pdu = kcalloc(pdu_count, sizeof(*pdu), GFP_ATOMIC); if (!pdu) { kfree(seq); return -ENOMEM; diff --git a/drivers/target/iscsi/iscsi_target_tpg.c b/drivers/target/iscsi/iscsi_target_tpg.c index c3a607b3ccc8..3298145f74f5 100644 --- a/drivers/target/iscsi/iscsi_target_tpg.c +++ b/drivers/target/iscsi/iscsi_target_tpg.c @@ -34,7 +34,7 @@ struct iscsi_portal_group *iscsit_alloc_portal_group(struct iscsi_tiqn *tiqn, u1 { struct iscsi_portal_group *tpg; - tpg = kzalloc(sizeof(struct iscsi_portal_group), GFP_KERNEL); + tpg = kzalloc(sizeof(*tpg), GFP_KERNEL); if (!tpg) return NULL; @@ -474,7 +474,7 @@ struct iscsi_tpg_np *iscsit_tpg_add_network_portal( } } - tpg_np = kzalloc(sizeof(struct iscsi_tpg_np), GFP_KERNEL); + tpg_np = kzalloc(sizeof(*tpg_np), GFP_KERNEL); if (!tpg_np) return ERR_PTR(-ENOMEM);