From patchwork Sun Apr 9 19:53:17 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: 9671781 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 7D31A600CB for ; Sun, 9 Apr 2017 19:53:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67F8C27D0C for ; Sun, 9 Apr 2017 19:53:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C1A227F4B; Sun, 9 Apr 2017 19:53:39 +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 18B0127D0C for ; Sun, 9 Apr 2017 19:53:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752440AbdDITx0 (ORCPT ); Sun, 9 Apr 2017 15:53:26 -0400 Received: from mout.web.de ([212.227.17.12]:54298 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752322AbdDITxZ (ORCPT ); Sun, 9 Apr 2017 15:53:25 -0400 Received: from [192.168.1.2] ([77.181.114.244]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MIvbh-1cvO1G45s1-002WKS; Sun, 09 Apr 2017 21:53:20 +0200 Subject: [PATCH 5/5] target: Use kmalloc_array() in transport_kmap_data_sg() From: SF Markus Elfring To: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, Bart Van Assche , "Nicholas A. Bellinger" Cc: LKML , kernel-janitors@vger.kernel.org References: <337dfdee-8a9f-9bb3-639a-ea47758966f1@users.sourceforge.net> Message-ID: <0e590666-0658-dbfc-1438-b378cb45cfce@users.sourceforge.net> Date: Sun, 9 Apr 2017 21:53:17 +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: <337dfdee-8a9f-9bb3-639a-ea47758966f1@users.sourceforge.net> Content-Language: en-GB X-Provags-ID: V03:K0:U9syBURbEgRh+7OaOGiVFeI/eGPA4iuZGNwBKPliRTPbS9Giv4T YH1r7NA0+dH2ABU3ndJU4PCpDA817EjEZiDgN+C/HG/TrcuWRCLWsHpbO/t+c1yo5HmJ43N +ajkP9/EuMNWvHgViRcBiY3EbZfkWPJXa+QlirTVfAInf8LNUjxoxSMGhhkeMbBAqhqdkyP i6hsyuhJ457OAje6vVNFQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:dqIWCuSh7/4=:xnwrK8UHdLm7N6jPEgo/PE ma3OGVOsfXSCrP39NNfBmHGmLYbTZDjVy7wzDDqQd9fhGtmP/PY5MZMu1hNwZjtAn/CrEuW4A ySs+3nFLjDy7VEVbHh2xIvV3LUC/yIqOK+ksa7+zaJdFNoIQj8kaMx5GshgRg+iX+fRxBp5Uj KmQawq1umb/Js9SCcro5C0cw9fmOhaWuP6f1NOHn4wVxW1Q5J//bi8Gj5ePWh/n1BxrvwGF+Z mE93MaW5JHl32bxHcCmHXiNBf+DAsck9wr7w/09fgxXjuzw3z5pQc4C/4RN5p8UkCiA7TbU7v Zwhe/JjQZpAONa5ual3P3xSp90vlukll5CMjfqBqqaDYCZP/1z3/j/qOi8ylrrhFDNT36oSvS NFyrs5VGi0PwzUVSd7XIIgQqA8M6oNsZlorTpJFN/mkIB6yEmbiuLqS6n+Ag+gXcpYsCt2jb5 VTVvP8I2INLDVWgfomvrq3g4Jw5ka8nzHp3A7EcpoKM3zN+kiZYpqN/7rll8EF+W4y3KVGNyR 5P2pWRTfUGNsUv8Hm4Tr79MalTMrPWamTHNKtZmfK4es1T9irjtCyb7h7wBQS8+tnKoXhVg8L cmcyoKaOLYKwXLgim9MX9BJQqkSratLGhozpFTgi2Y43WPGWp2zVOal3ck6dftbeCkGVUFY4E PAfGJ+FzMzmd+ly9gUoEvt5/76BxNx/hP4PP72lUxyoUcMucZ9XMn5iv6/YeGnhtFPZLC/+rP d+hx0BD6mLu5Lp+xwRO6APbcq/MvmqNuV/TR6/8Fd3jgXPdtHx22qLUVd8R/IxwzRNgZ/UDOh TSOsrsP 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 21:07:14 +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 "kmalloc_array". This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/target/target_core_transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index b1a3cdb29468..3ef1cadd3c32 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -2280,7 +2280,7 @@ void *transport_kmap_data_sg(struct se_cmd *cmd) return kmap(sg_page(sg)) + sg->offset; /* >1 page. use vmap */ - pages = kmalloc(sizeof(*pages) * cmd->t_data_nents, GFP_KERNEL); + pages = kmalloc_array(cmd->t_data_nents, sizeof(*pages), GFP_KERNEL); if (!pages) return NULL;