From patchwork Sat Sep 10 07:17:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 668338 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3sWQR52rw8z9s9x for ; Sat, 10 Sep 2016 17:18:41 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754484AbcIJHSW (ORCPT ); Sat, 10 Sep 2016 03:18:22 -0400 Received: from mout.web.de ([212.227.17.11]:65307 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751260AbcIJHSV (ORCPT ); Sat, 10 Sep 2016 03:18:21 -0400 Received: from [192.168.1.3] ([77.181.94.136]) by smtp.web.de (mrweb101) with ESMTPSA (Nemesis) id 0LvBV8-1azy4g0Hly-010KZK; Sat, 10 Sep 2016 09:18:00 +0200 Subject: [PATCH 1/5] ATM-nicstar: Use kmalloc_array() in get_scq() To: linux-atm-general@lists.sourceforge.net, netdev@vger.kernel.org, Chas Williams <3chas3@gmail.com> References: Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall , Paolo Bonzini From: SF Markus Elfring Message-ID: <698e4922-e671-f60f-4599-ad4d7613c808@users.sourceforge.net> Date: Sat, 10 Sep 2016 09:17:48 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: X-Provags-ID: V03:K0:6QLCkD4iUojgat/wfnkvDGnrNajX+oT1E+UEZqwQ0WVxyUM2H7y P40u3lR1yijVuYXTcqRkw8dAIpXHraXPu4Biii3MzJ6dURLtRj+DmFnn/eQZrsqfT/Mnv6O H7CXGvZFXQVG4kYSvXLLuwc/gtHFS5amyBEnU5Vw5sl1vZuXhD9lOCLJXzzjsMei+91Du35 xOmvP7Of1zWXP7gd+ezQQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:RKMEHfHZmKg=:6SdYxEUU6Yy97Mqxk/Vp6I JrAQ3uANbyh3PwcFzl80X0OYontilKkyiRgmk+YJlm78yQGnWHQ/Zz6lBcvISs4on2fOKN1VZ XZqYlFht8AygsK2lisopbUSZ93YBV8XM160TpcQxaoo45wm6lvGeR2CauMY73eC421aISNQ0I /9mDgAhxZY/UXjBJfLS5gxVZluoJkySS5WxvbTFRN7GhhJsRAEkRVjtsWn8AxXL4tNYTj24Y2 JvRsH/+peVKGscRwV+C0cEvVCRQ92TuG2UirPLwJ4Zdc4kY/qY950QJV53a7kPKUYSMW+omWm HzX6SOhHMjO0SwVeDEkZICi+FzxH1/lSMlPIV2ozBSi5NWfwmVOEL6jx+Xs4dK2iHB1nZ8hHS TpMvgZAhnCiNaIenyHjV5y8p3jECkE43Ui1YO2qgb9CrDsLpiGtc2ZxxcrX8EbIIRs4IM5X2l Ezx0ugW7Cyx1uM71T52csD+/Uxm7X4gr8rndWzGvKAOSeulcyrUuPZvBuKwiicKNz0JU7rKpL 719hL5Xk3swRPG1uICZ58PnMoJGrw+eocHvF2qiSfsMmRNq9An66RPnb+4ggU2uzOhOFGjYLx uo1H60bC7VTk89fE5Pqe+RtBKBosy1nM/L+uUQfxTUVcvlWg0SZ64KihchZ6QRQL9D3j2ZFjF uc8thfwaSsxBP1KOPQ74OfMAi3eb+ThgNnacHK4sZCwQpg2t43BCiIyvNY4JeqHr2qZb2LGc6 AEygiHHocztzCDIi0k3kXKZ58HoBly20EqvxnlX0iw02lJ75UiqXP+JmXgodYJSwa9jL/Uluq h5WyOp3 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Markus Elfring Date: Sat, 10 Sep 2016 08:02:06 +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. * Replace the specification of a data type 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/atm/nicstar.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c index 700ed15..50dec13 100644 --- a/drivers/atm/nicstar.c +++ b/drivers/atm/nicstar.c @@ -871,8 +871,9 @@ static scq_info *get_scq(ns_dev *card, int size, u32 scd) kfree(scq); return NULL; } - scq->skb = kmalloc(sizeof(struct sk_buff *) * - (size / NS_SCQE_SIZE), GFP_KERNEL); + scq->skb = kmalloc_array(size / NS_SCQE_SIZE, + sizeof(*scq->skb), + GFP_KERNEL); if (!scq->skb) { dma_free_coherent(&card->pcidev->dev, 2 * size, scq->org, scq->dma);