From mboxrd@z Thu Jan 1 00:00:00 1970 From: SF Markus Elfring Subject: [PATCH 08/10] pinctrl: imx1-core: Use kmalloc_array() in imx_dt_node_to_map() Date: Fri, 14 Apr 2017 11:20:55 +0200 Message-ID: <7e8a5c9c-aa4c-0675-3690-dfe1fed56915@users.sourceforge.net> References: <59fae4ac-9e07-232a-4843-92dd9e0cf2ef@users.sourceforge.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Return-path: Received: from mout.web.de ([212.227.15.4]:59114 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751360AbdDNJVK (ORCPT ); Fri, 14 Apr 2017 05:21:10 -0400 In-Reply-To: <59fae4ac-9e07-232a-4843-92dd9e0cf2ef@users.sourceforge.net> Content-Language: en-GB Sender: linux-gpio-owner@vger.kernel.org List-Id: linux-gpio@vger.kernel.org To: linux-gpio@vger.kernel.org, Arnd Bergmann , Gary Bisson , Laxman Dewangan , Linus Walleij , Paul Gortmaker , Peng Fan , Shawn Guo , Vladimir Zapolskiy Cc: LKML , kernel-janitors@vger.kernel.org From: Markus Elfring Date: Thu, 13 Apr 2017 16:10:33 +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 structure 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/pinctrl/freescale/pinctrl-imx1-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pinctrl/freescale/pinctrl-imx1-core.c b/drivers/pinctrl/freescale/pinctrl-imx1-core.c index a4e9f430d452..5a0d221ed09d 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx1-core.c +++ b/drivers/pinctrl/freescale/pinctrl-imx1-core.c @@ -246,7 +246,7 @@ static int imx1_dt_node_to_map(struct pinctrl_dev *pctldev, for (i = 0; i < grp->npins; i++) map_num++; - new_map = kmalloc(sizeof(struct pinctrl_map) * map_num, GFP_KERNEL); + new_map = kmalloc_array(map_num, sizeof(*new_map), GFP_KERNEL); if (!new_map) return -ENOMEM; -- 2.12.2