From patchwork Tue Apr 18 20:02:45 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: 751963 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3w6wzP5vKhz9s65 for ; Wed, 19 Apr 2017 06:02:57 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932679AbdDRUCz (ORCPT ); Tue, 18 Apr 2017 16:02:55 -0400 Received: from mout.web.de ([212.227.15.14]:59363 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932475AbdDRUCy (ORCPT ); Tue, 18 Apr 2017 16:02:54 -0400 Received: from [192.168.1.2] ([77.181.207.195]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MJlCO-1czTP82PmG-001BRL; Tue, 18 Apr 2017 22:02:46 +0200 Subject: [PATCH 2/3] ata: libahci: Use devm_kcalloc() in ahci_platform_get_resources() From: SF Markus Elfring To: linux-ide@vger.kernel.org, Hans de Goede , Tejun Heo Cc: LKML , kernel-janitors@vger.kernel.org References: Message-ID: <75fcbbf1-5011-e6fe-7999-7286ffe742a0@users.sourceforge.net> Date: Tue, 18 Apr 2017 22:02:45 +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:VorzxHqtdQKGIVdOVPJ799rL1gZfI9Xq1z56LcROkCmjUSaQiST mkbhk8vSpwpNe4hkMqI+x+n+OfStiD2N7JfSL+EB9cdBO35QayciO1xkogBYjMA+LPksOaU k3/48sMkaRldzsQfOM9X7bnd44IgGdbX7Pj8xSKn6TV9Qww/GyO8+ap+LkZK/602DdL/KPe ppRfAS1VF/qolU/d+6cJg== X-UI-Out-Filterresults: notjunk:1; V01:K0:4lmZvo/mLXE=:PiwrEWUnNgG5TCM2nJEDlJ NpucUFF/T6QrN5PRI8VJNH5A5MZaecvM5ehyl+VM/zQ1AEo2C02chJfA9PYTdAQxTgmE7UeTp nEi5967vhZ8YFSL0JEB9qVocLn0WuWtii9Wm+OjlcjqRqfd+FH+sTvKdLKZgeiXswvtXlWyMr BlD1223NL1cBqo1FxqyWvPE6gMNHj2LY9LETyNOKk8XJ2j3zVfLZLDWCMGkv9aODUVrhLKh0s ejsyeIHDr1TmunEDt18OwoO/zlB7NT1GZ31oLiYa/HgFh5nM0XlZaMLwFspOuCSRDhZqi4iAl vdSgwS62Czly4LqSSYwiCz3+rLt65Y6uy7tKrnxojEp9V5/Fx0wv85UM6uhCiRQQUo4NDZh/4 /mz/DN7RMMsD07a533H+8qdislZp4b6qti+FFhs9BD/8iuheEAo/KMubFpLjrmHj3ijSINyxU XEvtTbwky+nfEMo1d2yNKT5XSqeOsk8AFnGTIJAAhVfrXGxcxJz2kfg7Y47Ib3SPt6WEQj4ci RrQBQrwm9KVx9wj5qhKWPm0uneBxoIGGUysrEgHbULbeWNFkOjwt4bMWDzZnGdLHHMlF5oGzY mdr4+2jzoSJiw7D/pvbU84UQMoFwhsf75Ji3xAIcNDox1WsFa5ldqyeHSWEmwE8CmjnEQBY3q dRtwjhx9y5ttaftlP16IuZEd2psI51XHyR8EFtyfqvuzRcZT1u+4ziQjD0AF292ScfxejUwZn 4SzcOPArs494r+0u1WZvy9y432L5ja3gFEQRKBgP8E+ujbafd1iQodjYQSt2LZ/k3KvbsFExy 39Kce4h Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org From: Markus Elfring Date: Tue, 18 Apr 2017 21:15:48 +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 "devm_kcalloc". This issue was detected by using the Coccinelle software. * Delete the local variable "sz" which became unnecessary with this refactoring. Signed-off-by: Markus Elfring --- drivers/ata/libahci_platform.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c index c68ea903b5bf..2bce61f7482f 100644 --- a/drivers/ata/libahci_platform.c +++ b/drivers/ata/libahci_platform.c @@ -350,7 +350,7 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev) struct ahci_host_priv *hpriv; struct clk *clk; struct device_node *child; - int i, sz, enabled_ports = 0, rc = -ENOMEM, child_nodes; + int i, enabled_ports = 0, rc = -ENOMEM, child_nodes; u32 mask_port_map = 0; if (!devres_open_group(dev, NULL, GFP_KERNEL)) @@ -402,8 +402,8 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev) if (!child_nodes) hpriv->nports = 1; - sz = hpriv->nports * sizeof(*hpriv->phys); - hpriv->phys = devm_kzalloc(dev, sz, GFP_KERNEL); + hpriv->phys = devm_kcalloc(dev, hpriv->nports, sizeof(*hpriv->phys), + GFP_KERNEL); if (!hpriv->phys) { rc = -ENOMEM; goto err_out;