From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753693AbcHRKEY (ORCPT ); Thu, 18 Aug 2016 06:04:24 -0400 Received: from mout.web.de ([212.227.15.4]:62827 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752965AbcHRKEU (ORCPT ); Thu, 18 Aug 2016 06:04:20 -0400 Subject: [PATCH 5/5] block-cciss: Replace three kzalloc() calls by kcalloc() To: esc.storagedev@microsemi.com, iss_storagedev@hp.com, linux-scsi@vger.kernel.org, Don Brace References: <566ABCD9.1060404@users.sourceforge.net> <686a1f95-a76c-2624-50e1-9d0e59948e64@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring Message-ID: <8f32c3e7-bfb6-f88b-4894-338b94a0d1da@users.sourceforge.net> Date: Thu, 18 Aug 2016 12:03:28 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2 MIME-Version: 1.0 In-Reply-To: <686a1f95-a76c-2624-50e1-9d0e59948e64@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:CX6ioSDT/pz8MTh3Uc2mO+l6s2MiysUaO2Gjhzg0clNFzj626Uu wJFJU7j44OQD0fiPQC6bgxT02MtCHWbuXcolAboSkxoU33tU2AviFiblB1HG8ZuhaAm6zlY 4AGVzksB6h+G4shpes4fsWCOWmD/3e208wGutlglz5Zco9coTJbw9yR1Aey3e8Rm/ku3vgu 1WIUIhk1uFJ7jSEGcW0uw== X-UI-Out-Filterresults: notjunk:1;V01:K0:lM/UGmXl/yI=:j5HQxxeTLiRQWCVrZlFANR iJHiYldAGhQWmalChS/Ho70o2o0LQoN5QhQwE06XkxL+iUy2SzLr/T6Ne0u7PdG7Mo9axO9r1 +WZkb82eOc3ypsi59kYXJ9OJ/SfjdHMPcxZ8dLciABz5q4LZ3d/JhxuG1fB7hNGwjBkAyvcF8 Qb4t8rFqXlI8InoqwLhi0BqC4PVVtBsNVnbntEZW79ammhGOyrNVzVJodCrJB8VT55d1G3IDo eeKASvNzBAilqJeyEGPaXtaFEk6ztfi0dl0MeyigG4AHFLtZr/9u45qLIz2+BTOJkYqr2PKPi wTZNXsM4b+RrUihUVQHjQys9eL34PJyewBrxbuwHpL54OOOouoiR4wtH5oelNOjqRIMkXWdhb 2HbwppAWkFvYKLUE1bJDvtJagRXfu4kAk9N/uCCeV5NF2cWBEwll5gUuEnEpDPnzOjNml6IHl f6gbFIxNj0dav6/mYPVE6DIFcMQV5Xnt8z9IJmu1abGNtZ8PKTSpKZzHKKrwd4IkqTZPt5Eml 9q16QS/nf1Cl8MuI9UVGOHqciOMnjXoSWx0LNpo66nJGgTzsTK3mybhUIsIbqjKi0wSZXDB50 hY20eXW65jOVQF+dLNmwjNqBMkSzf1Yvt9Ckc4TjYCGdn1tJ8LNIfQz46fmSTzMRZBv5Q92Kw J213G4jeuiplxE/86P3VO9cNKd2Q+zhg03x2EQFxMdXOWqgoEkAcnqVlgQOFCMI4j1FF9xXpY zwLI5KVPKBFTF1mlEYDV6YVLeC6KSIwwwqCWIoJVWckR1ehfybNbRkAJVvSwRYRRS4eaiVWoY p9xG084 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Thu, 18 Aug 2016 11:26:18 +0200 * The script "checkpatch.pl" can point information out like the following. WARNING: Prefer kcalloc over kzalloc with multiply Thus fix the affected source code places. * Replace the specification of data structures by pointer dereferences to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring --- drivers/block/cciss.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index b08bfb7..3502a3a 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c @@ -1604,12 +1604,12 @@ static int cciss_bigpassthru(ctlr_info_t *h, void __user *argp) status = -EINVAL; goto free_ioc; } - buff_size = kmalloc(MAXSGENTRIES * sizeof(int), GFP_KERNEL); + buff_size = kcalloc(MAXSGENTRIES, sizeof(*buff_size), GFP_KERNEL); if (!buff_size) { status = -ENOMEM; goto free_ioc; } - buff = kzalloc(MAXSGENTRIES * sizeof(char *), GFP_KERNEL); + buff = kcalloc(MAXSGENTRIES, sizeof(*buff), GFP_KERNEL); if (!buff) { status = -ENOMEM; goto free_size; @@ -4838,8 +4838,9 @@ static int cciss_allocate_scatterlists(ctlr_info_t *h) int i; /* zero it, so that on free we need not know how many were alloc'ed */ - h->scatter_list = kzalloc(h->max_commands * - sizeof(struct scatterlist *), GFP_KERNEL); + h->scatter_list = kcalloc(h->max_commands, + sizeof(*h->scatter_list), + GFP_KERNEL); if (!h->scatter_list) return -ENOMEM; -- 2.9.3