From patchwork Sun Apr 9 14:23:41 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: 9671565 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 8D66C60381 for ; Sun, 9 Apr 2017 14:24:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D09D283FF for ; Sun, 9 Apr 2017 14:24:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 687BA2846B; Sun, 9 Apr 2017 14:24:58 +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=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 217FF283FF for ; Sun, 9 Apr 2017 14:24:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752338AbdDIOYc (ORCPT ); Sun, 9 Apr 2017 10:24:32 -0400 Received: from mout.web.de ([212.227.17.12]:51243 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752198AbdDIOYb (ORCPT ); Sun, 9 Apr 2017 10:24:31 -0400 Received: from [192.168.1.2] ([77.181.114.244]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MPpQU-1d15Mn2oHy-00532G; Sun, 09 Apr 2017 16:23:47 +0200 Subject: [PATCH 1/3] iscsi-target: Use kcalloc() in iscsit_allocate_iovecs() 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 Message-ID: Date: Sun, 9 Apr 2017 16:23:41 +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:y8+fZKgqvC4crxF54Qz6X1pwbu5fRAgFyEX432/Z2pOUkhTJ7Y8 qA/ugQHGnbfa3TWhf6EH+uC90x0GnHjnOinmRXEcLnC6VnAMzZERlZglMIcPVXpDCzX0Xy0 HBurwNBlty5WXy5gCudiAm3YRm4sMru0sC2Z+0uYPSJInfz/Yuuk60zj6uMzzgq92r9LCvZ B8b8LE0MQklSLIUMloRgQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:Ih43/fpko/o=:3ojeU2Ae3GWlSOzFSsDoWN DNSA+nB43DIKU5ZkLYVzqLyYrPUwDeh7gwM6HNagxL8l368laRQ82QYTdvY48ttKTWusP3vj2 SrXWn11znnZvskgjivfBdppwk8k/MlB3gsrFXGMRMBw/lyGp/lGdT2dflYxbK73S/BDxYczNv +LqUbY1tr8G54Qc7dIouAakFLUc7I/PpPhBkXx6lWbltICIPcbPTbq9lVl5SMKB8iRns9BAuO hl2OlOx/M9jSjCpwDWHIuLXKzS5C2OquoLb4smtw3hhPi5WodaT7U5pAbPrJuBlE0wO8XEfJ7 4SsPoNhN48KLM7ydp25biW7twskkqTyMUuR/PgLfFiXddaJ8Q7Ah632RIW9rk7BLk0vOxY8Jj 7I0RasF2NAwikdFuiZVU/6+jswvl8i2abNglghhYl+c7NbGkA8TC+P65oGUWTHp5vvZ0sgHyn Mpxj/kve/6ARaznw00YI3lbyeXr5XBfqbGyreyeALIvLc7stmpZO2Aqf2SkjJsLh2taKGGSkZ PiEsuaYpQ+E1mboa/fiBy014x95HHPFd9TezJ0CeiGnvgWYMihxwzl8/n2Y3xBKzjZQFrCayD 4Csbo/oNrnyaEbftihGeaF2wtkCy/Ez436MtXpAidyNgznTKYoKK0DeYm3o2CFvRMJCoLeHfl OlRjWOG8FVfhQYzZdrplQUAjm5sK/IrePTM5R/ywFWCZu5wW6lFuYxrxYZzH/pltX77y4ol+/ Mp9ZBFRvCCfXFEABR7FMOfbLt/ROgz6KB/SGg+FRbVEGPfkpn/8J0HRiKx1YwmtmaAWpjAaCK 2ANvZpe 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:06:00 +0200 * A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus use the corresponding function "kcalloc". This issue was detected by using the Coccinelle software. * Replace the specification of a data structure by a pointer dereference to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring --- drivers/target/iscsi/iscsi_target.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index a91802432f2f..536b939afe9d 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -985,8 +985,7 @@ static int iscsit_allocate_iovecs(struct iscsi_cmd *cmd) u32 iov_count = max(1UL, DIV_ROUND_UP(cmd->se_cmd.data_length, PAGE_SIZE)); iov_count += ISCSI_IOV_DATA_BUFFER; - - cmd->iov_data = kzalloc(iov_count * sizeof(struct kvec), GFP_KERNEL); + 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"); return -ENOMEM;