From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932442AbdDRUBy (ORCPT ); Tue, 18 Apr 2017 16:01:54 -0400 Received: from mout.web.de ([212.227.15.4]:50787 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755558AbdDRUBw (ORCPT ); Tue, 18 Apr 2017 16:01:52 -0400 Subject: [PATCH 1/3] ata: libahci: Use 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: <11086550-7b2b-9284-1512-fb501904f8a2@users.sourceforge.net> Date: Tue, 18 Apr 2017 22:01: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-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:0+Dzm9FUNOQhWtjxtVRv46wwKhjSNUHkY8VShsnjN4feAIwu+rN 411nMbV0ub9GGyEKQg2QDmBLinqOo/ELHXWI3cH18CKz8QzmDwZt2mZl49ARjUNwbQjBI4a fTPc+sNGL3sRmxFcYJuXvGz/hfjSIx+3jUjjJcS9wCuqzAODkU9dAIUODa28VvmYQ1K1Suq afsNT6UqEmEZjfRj/WfFQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:mzQqOjr6wcY=:JPf9m2l4dUZFT2RaCC3ppp d/NyNptsoZ1TyX/6oM9ZkH5SJzu/C7OiJhUUv87HgH3gE1Z1mKFY8WGbsgz/jQbr8LGwNhZ5y Q3LSRm2NLPUD13RQs4q9rADLiUvBKx6otO3QHjYoA+lPGyyx3wfw0yoKlimUFeV4RB+y8fEyl K6ZylrZ7ZhnjCkFAFNOYL5kO7PocDReUtHUqFja+9H0xu8SiExVRyamEs2zb7NaUMKG9VSUV/ Icz8we9gxi1ex13ygUZgA9C5udaZWzKXYs6/U5Qnfq94j1Wh/ClF7Bj/etLhZPAsphQcV0goy ZGPn5jYhXB2WT24qvGDPE0yBFFx1zauO2gI84B1vRn2Wkm8XyhFv1dzlcR6DKdk+XOsXhfZpj z5q6ydF199Kb8l9qVhJQhun9BAdFqTjZ9ypi7rJKyTWjmt8xaTJOkc1R5swWlDS4zIvLTD2F3 752fVckApRLeo+14r8qf17SWzIhG8gScN2sSKlSIud9lalMlDPEplCwo+AmQ9rUNosJq1V84A QmbYmvw91JY8buU1VRVrNB+iPthCAAN6ONG99bikmW9KljsHNaR8BVue+CRe7MBph3e4BKHKL 2+hsII1izjZj5+HLswltxQGDOX8/8XuB0nYgsJUjwZO0f7go+h+Mt4fi/IXdtTIjLeURQNDzs /VtbhfzObZjkdENxlTWGbpu4HIMG6mguBEu3zgTVBIxbO7fc3pnLkX+oho2QJjdC8+SCHHEr+ /T/sKqhAwBOOpPtc+jxitCeFoDIXAPUTePr3xppLAehUfEKBmtczh/cGUAqv0xIX1xCggDf65 FAGJA3w Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Tue, 18 Apr 2017 21:07:34 +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 "kcalloc". This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/ata/libahci_platform.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c index aaa761b9081c..c68ea903b5bf 100644 --- a/drivers/ata/libahci_platform.c +++ b/drivers/ata/libahci_platform.c @@ -408,8 +408,9 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev) rc = -ENOMEM; goto err_out; } - sz = hpriv->nports * sizeof(*hpriv->target_pwrs); - hpriv->target_pwrs = kzalloc(sz, GFP_KERNEL); + hpriv->target_pwrs = kcalloc(hpriv->nports, + sizeof(*hpriv->target_pwrs), + GFP_KERNEL); if (!hpriv->target_pwrs) { rc = -ENOMEM; goto err_out; -- 2.12.2