From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752758AbdHJNDo (ORCPT ); Thu, 10 Aug 2017 09:03:44 -0400 Received: from mout.web.de ([217.72.192.78]:53673 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752091AbdHJNDj (ORCPT ); Thu, 10 Aug 2017 09:03:39 -0400 Subject: [PATCH 3/5] ASoC: dapm: Use kcalloc() in snd_soc_dapm_new_widgets() From: SF Markus Elfring To: alsa-devel@alsa-project.org, Jaroslav Kysela , Liam Girdwood , Mark Brown , Takashi Iwai Cc: LKML , kernel-janitors@vger.kernel.org References: Message-ID: <62be9e32-1b8d-3980-7998-72f82c62a6fe@users.sourceforge.net> Date: Thu, 10 Aug 2017 15:03:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 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:65LHvsXNxDukommQ0bQJ5hKgt3IB6bdR/T3s859Cfyvlt5dY1hp U+kSH+YtG0IGE10gEBWGjeZGZWlljTXkCjNeAvINJFHentBEaPacqFqCqZN4Fs6xpGv4xYi WScbC23aXPhRSkASw3Lv0bzP/ogIoiq0fp3ZBBvqvesXAOciRf3eMAvOn4OuxycLU786aG+ nvzGB/pC8thsdZdv5UHkg== X-UI-Out-Filterresults: notjunk:1;V01:K0:l/l+Dfbr5ew=:ztv8zzTlCX/iRenNRAWbqM 3ZaqoKH7aGtmntv7+uuYrw1iVR6h5mGOT3QPMJUbAtCJS/DFCKXN5Ch2eoB3PncpSUGMOoIFr oOxtEQslxsB5Ky58lWbfcewkDe4l/5M+87HhCchdA+kLGy05uwJO4fyL3Rh8BmCYaJ+Dm/4QM t1Z6qamRZMiWN/hCINgzA/Ze7cWpKJJevmuRJcrIqH7LpsZ/79ydG8qWGSK6r9wR1FOwZ4bug ZQW7JzwJtbirNdx3dICQ/sYgQzAPDKvVvEkzUMdKz+hK/LVp805jLujIO72DKVFVA15m+nvvW zUT2FDtG0C5JxqjSidWS+Yie8GmKrzSgHbBxFYkNbgmQRtytBvh+6vex8wTvhjOhKpUZspX9p mB2xUrcrleB3Q10EWOko4MAzTXldYjLX8g1q/dKS+7/IxrukfLRITVNgLJDp955BnGQQsCi7o SpEGVVG9Cfnlwsu1Ia/3sPH8oL6RJkW6PXz26FFfhHfrE7uWZlEaedYDHMWTSNXc3f6ASc0g5 4Eyjph18xLFLEFbPuPm7u+XEpqtcwpK74SvXO2sShZ50Ex0WWRSOgOSL1OoQsWJrtT6NogIQc vcTizH+quit5ghdNuDr0YYvZqn6IpzkhqUYDrE42wm60JGVzMq+hwIW/JR9j5kmMa8AIU5MKG 3LZlHK5xXz6Y7CTRtqNt5VYvjVD2ziwjQ55lA7jqIYCB1fF5xV+OVKkx31EqWFb8Is47T2b1T f5cohKNOYR5gMP8gHkEzru4AHvQaQDr5gmIL+NZRhweIJHXQSxq7TB5tmkC/OJr31JYL1jqT9 4PN30KTiQia9a5uQYF5aFL6hj6n4N0E4ZXutPgq+be9nhuqVIc= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Thu, 10 Aug 2017 14:30: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 "kcalloc". 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 --- sound/soc/soc-dapm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index e673961210e6..3fa9f023bff7 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -3027,9 +3027,9 @@ int snd_soc_dapm_new_widgets(struct snd_soc_card *card) continue; if (w->num_kcontrols) { - w->kcontrols = kzalloc(w->num_kcontrols * - sizeof(struct snd_kcontrol *), - GFP_KERNEL); + w->kcontrols = kcalloc(w->num_kcontrols, + sizeof(*w->kcontrols), + GFP_KERNEL); if (!w->kcontrols) { mutex_unlock(&card->dapm_mutex); return -ENOMEM; -- 2.14.0