From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S970604AbdDTU1E (ORCPT ); Thu, 20 Apr 2017 16:27:04 -0400 Received: from mout.web.de ([217.72.192.78]:54980 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S970309AbdDTU1C (ORCPT ); Thu, 20 Apr 2017 16:27:02 -0400 Subject: [PATCH 1/2] firewire: ohci: Use kcalloc() in pci_probe() From: SF Markus Elfring To: linux1394-devel@lists.sourceforge.net, Stefan Richter Cc: LKML , kernel-janitors@vger.kernel.org References: <1139a329-f084-c4f3-d9af-19ad15445017@users.sourceforge.net> Message-ID: <8d17e44a-054c-f7e2-ada2-db80ec148287@users.sourceforge.net> Date: Thu, 20 Apr 2017 22:26:29 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0.1 MIME-Version: 1.0 In-Reply-To: <1139a329-f084-c4f3-d9af-19ad15445017@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:t86hgWPGPD30uFJpWnNssYSEZf5DFLK7EStCP2SCIMbOMTyJqvI jAdbY+V+h4qZti4m4kt0BKEJJ4SCp6I7rjow4XkzUIgyQ18pBsUJhU7UtgrYFqaHsnPFltp vyFkifMOMeNuMAfTohGrg4HfOwQtuMwfPO1DNAuegVgPN3ZPM/NyERzVodkBchUZbQfiqMQ Svbb/dOwdwfMJjSKDojLg== X-UI-Out-Filterresults: notjunk:1;V01:K0:kEg4RQSGYlQ=:CGMTeXrNc3bYrAY0uKsM1z gDuK+3CjuJ4908jK1fcWkulBvlTi3RHi/A2zWWz+Kjolz5t9SxNtBoSU9aJHLJLx2b9f6eMQp GWIQKdijGegP9egPexlEFQVMwrk+M3fMAi3kqatUqE52s0Cy1ujctHH7vPlNsq2e11BQSz9eT NHU6cc7QsxR7taq+/0McjWKV056FhGeScO758VyDAj5x/5fS8IhmcE8rFFERpVaziJwSfZnr1 Sqlpegpt6432Qs1OZyJ4xR/GMSgfj857OGWTzSrDSeuBkL67cA6vGZUqzo4merOt4mNrqkD1x PtXLk24aoZnBQ8Qs4mWtS15VCSk6Nbo/L7ArhaVkhnyflhrIubIP2BHc7GnFviIsCBJtPbx9i EbW+BmkkdiCsyDr6Cv8OpxRg44jVpeh8lw58ke3NlwFf68l0Pg7YyLocwCsclL2wv1e5Cieq8 GjvJijUW3maoOLLy+wN8JShCN5h3taWmSDCODcmDT1JCJqoxrguK1H5Y8buXj0svtqsIH0nJw N49Ajgx1oqZEjLnd+2XEV+nyHGusVB1/M+rp+0hJs686OX1EiArp7h/uqbak1H1Okx64FrBDI rXZJVXAtmWC1d/AItDc6dwTb4O2sQ2I0tZh2lqAsud4o0iivlworSDjEEAS77ItpqtB8LW61p oYC/dRb5OIsKCjPB0lWzOzh80uZfCQ4WvQsAvXoNTOxFnCggWL7ChLtL0BDuGm1IERHEXl1Hm tMULfxBTJ0f3hWFo9P/P3OcHRp4xxDjVrKCm9Kyi72Pq/nDP3+2bL9BBxKOcPTSetUTvE8BQX 2mmO86B Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Thu, 20 Apr 2017 21:50:19 +0200 * Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus use the corresponding function "kcalloc". This issue was detected by using the Coccinelle software. * 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. * Delete the local variable "size" which became unnecessary with this refactoring. Signed-off-by: Markus Elfring --- drivers/firewire/ohci.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index 8bf89267dc25..30be5dbd5b09 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c @@ -3565,7 +3565,6 @@ static int pci_probe(struct pci_dev *dev, u32 bus_options, max_receive, link_speed, version; u64 guid; int i, err; - size_t size; if (dev->vendor == PCI_VENDOR_ID_PINNACLE_SYSTEMS) { dev_err(&dev->dev, "Pinnacle MovieBoard is not yet supported\n"); @@ -3671,9 +3670,9 @@ static int pci_probe(struct pci_dev *dev, reg_write(ohci, OHCI1394_IsoRecvIntMaskClear, ~0); ohci->ir_context_mask = ohci->ir_context_support; ohci->n_ir = hweight32(ohci->ir_context_mask); - size = sizeof(struct iso_context) * ohci->n_ir; - ohci->ir_context_list = kzalloc(size, GFP_KERNEL); - + ohci->ir_context_list = kcalloc(ohci->n_ir, + sizeof(*ohci->ir_context_list), + GFP_KERNEL); reg_write(ohci, OHCI1394_IsoXmitIntMaskSet, ~0); ohci->it_context_support = reg_read(ohci, OHCI1394_IsoXmitIntMaskSet); /* JMicron JMB38x often shows 0 at first read, just ignore it */ @@ -3684,9 +3683,9 @@ static int pci_probe(struct pci_dev *dev, reg_write(ohci, OHCI1394_IsoXmitIntMaskClear, ~0); ohci->it_context_mask = ohci->it_context_support; ohci->n_it = hweight32(ohci->it_context_mask); - size = sizeof(struct iso_context) * ohci->n_it; - ohci->it_context_list = kzalloc(size, GFP_KERNEL); - + ohci->it_context_list = kcalloc(ohci->n_it, + sizeof(*ohci->it_context_list), + GFP_KERNEL); if (ohci->it_context_list == NULL || ohci->ir_context_list == NULL) { err = -ENOMEM; goto fail_contexts; -- 2.12.2