Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756238AbdDRJlR (ORCPT ); Tue, 18 Apr 2017 05:41:17 -0400 Received: from mout.web.de ([212.227.15.4]:60325 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932080AbdDRJkv (ORCPT ); Tue, 18 Apr 2017 05:40:51 -0400 Subject: [PATCH 3/6] clk: hisilicon: Use devm_kmalloc_array() in hisi_clk_alloc() From: SF Markus Elfring To: linux-clk@vger.kernel.org, Jiancheng Xue , Michael Turquette , Stephen Boyd Cc: LKML , kernel-janitors@vger.kernel.org References: <7a649967-8ff1-8682-2f87-43871172fc28@users.sourceforge.net> Message-ID: Date: Tue, 18 Apr 2017 11:40:22 +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: <7a649967-8ff1-8682-2f87-43871172fc28@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:MOiXfZqrujtuPgjDpMlWQW5FhvCarzAPVw+FnBhCbi9UKYA6rDz zNgkK65PqfGuimLyspVnwOpYMz7jmavKnVznuu1ZgSA5UfPt333lnJbs1+uyevGFqOmkG2H TFpFATbxlVKuOk0Nw+ubuWnmNTnnW7O/qIZm294ALAousd9bWpUs17XaX8Ysug/CNAPpP82 EJ3pautScPgFtrAR49KeA== X-UI-Out-Filterresults: notjunk:1;V01:K0:77/XnU5iGwo=:/koveZEVJRUyxHpbIwqUFN pHOU8ptc0ZOV/X30hkMwzxyZ1Mak43yiJ2ta9lH6azmBJXDgZOBdrnQbRRLf6dBG+E8oPphOs iZbmjMtG2KGIqswPrf8qGX8lFR2pcjITh+YZIEKGEXtPmABqbNaA06BxzI5s/X6qD5d8KaEMF 2SRFPB2bYkk18dtoGBQ0e1y/yxCaLtfiLvQrIr2fs5paPCXjdwJkeHK2PRLQfsKnhwAFZbAvn 3fT28jAvOpMmasZHAnT3pZV5YQR3ZyvIJ1L88YpmmJpSOsy/p96FqRyOD1uQb2vZKr4GZtY4I RuLZYqBASgS+RDtkmploypsJdBH76GD4JdezbVOfEE9n4sykxaKoHuYstfaKMB0BmyD4LGZzO Zi4deqUtnTpVZCHYQIbpjAMFZkduLyMdnVAmF5iOkjdwSicfmP2ubTvVzPEG/Da1rb5Cydc1f AcY3ah50hxeQdGSyGrajupqbs7cifuEAqhmmq9TXP1K8rZa0a8C60iSfAnuj6t0hLAdLg7QQ4 UIwD/aAz9nBHGd0ixB8ttJn1UqzzN0kXZAX1Q5HWLzfLeKsNWzQ/Irg3oIRS8ndSOERvBh64m fL04ox9CLimg/lbIOjmaTG2vAPzeR3ELdbKRSZRhbbpvvFxYwIyMovnHiw0ePw7rnG6weJnKH ecF63+YfErnI5+E7YTWNKcuNoHpkOcYwE5FWqTHOgS6D4z4un7nNaTfvxpbcb0ZdUzg3V3b+g FlQwypGbvZJHjKtKVgn1OE5Q3nSyeElanAhW5/5nLBeykCsqb4v+mcRER13rtK9/pUJZm5d1f 0mxL5M0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1232 Lines: 36 From: Markus Elfring Date: Tue, 18 Apr 2017 10:15:19 +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_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/clk/hisilicon/clk.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/clk/hisilicon/clk.c b/drivers/clk/hisilicon/clk.c index eca4c66e316c..b73c1dfae7f1 100644 --- a/drivers/clk/hisilicon/clk.c +++ b/drivers/clk/hisilicon/clk.c @@ -54,8 +54,9 @@ struct hisi_clock_data *hisi_clk_alloc(struct platform_device *pdev, if (!clk_data->base) return NULL; - clk_table = devm_kmalloc(&pdev->dev, sizeof(struct clk *) * nr_clks, - GFP_KERNEL); + clk_table = devm_kmalloc_array(&pdev->dev, nr_clks, + sizeof(*clk_table), + GFP_KERNEL); if (!clk_table) return NULL; -- 2.12.2