From patchwork Tue Dec 15 03:03:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 11973629 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3E6FC4361B for ; Tue, 15 Dec 2020 03:04:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 662EE2246B for ; Tue, 15 Dec 2020 03:04:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 662EE2246B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 093C66B0080; Mon, 14 Dec 2020 22:04:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 068966B0081; Mon, 14 Dec 2020 22:04:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EC05E6B0082; Mon, 14 Dec 2020 22:04:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0168.hostedemail.com [216.40.44.168]) by kanga.kvack.org (Postfix) with ESMTP id D739B6B0080 for ; Mon, 14 Dec 2020 22:04:02 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id A79A08249980 for ; Tue, 15 Dec 2020 03:04:02 +0000 (UTC) X-FDA: 77594022324.21.crook17_4306dd227420 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id 83FA7180442CD for ; Tue, 15 Dec 2020 03:04:02 +0000 (UTC) X-HE-Tag: crook17_4306dd227420 X-Filterd-Recvd-Size: 3830 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Tue, 15 Dec 2020 03:04:02 +0000 (UTC) Date: Mon, 14 Dec 2020 19:03:59 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1608001441; bh=JW4Imt+K+37fiY/SyJIMfmpxhT/hULA93j9jMDC8RW0=; h=From:To:Subject:In-Reply-To:From; b=ajKqWdL7dJEQ+JgIG9d2WlbzTS9U2mNwopLUhRYKUV7M/nWQt/gt/XQ/cecQbcFtQ H4kG415LX8z1G/tpB9oKDQFiY84QxbiulGoOYSD6B3HBmtH6c0gqmZ0g1lYeSYrH8c SDSkMYc0xQvHUKwSrF7CTLuB6TJCE0GLmSUgmaq8= From: Andrew Morton To: airlied@linux.ie, akpm@linux-foundation.org, alexander.shishkin@linux.intel.com, andriy.shevchenko@linux.intel.com, bgolaszewski@baylibre.com, bp@alien8.de, bp@suse.de, christian.koenig@amd.com, cl@linux.com, daniel.vetter@ffwll.ch, daniel@ffwll.ch, gustavo@padovan.org, iamjoonsoo.kim@lge.com, james.morse@arm.com, jasowang@redhat.com, linus.walleij@linaro.org, linux-mm@kvack.org, maarten.lankhorst@linux.intel.com, mchehab@kernel.org, mm-commits@vger.kernel.org, mripard@kernel.org, mst@redhat.com, penberg@kernel.org, perex@perex.cz, rientjes@google.com, rric@kernel.org, sumit.semwal@linaro.org, tiwai@suse.com, tiwai@suse.de, tony.luck@intel.com, torvalds@linux-foundation.org, tzimmermann@suse.de, vbabka@suse.cz Subject: [patch 014/200] ALSA: pcm: use krealloc_array() Message-ID: <20201215030359.9w88ckWqU%akpm@linux-foundation.org> In-Reply-To: <20201214190237.a17b70ae14f129e2dca3d204@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Bartosz Golaszewski Subject: ALSA: pcm: use krealloc_array() Use the helper that checks for overflows internally instead of manually calculating the size of the new array. Link: https://lkml.kernel.org/r/20201109110654.12547-4-brgl@bgdev.pl Signed-off-by: Bartosz Golaszewski Reviewed-by: Takashi Iwai Cc: Alexander Shishkin Cc: Andy Shevchenko Cc: Borislav Petkov Cc: Borislav Petkov Cc: Christian Knig Cc: Christoph Lameter Cc: Daniel Vetter Cc: Daniel Vetter Cc: David Airlie Cc: David Rientjes Cc: Gustavo Padovan Cc: James Morse Cc: Jaroslav Kysela Cc: Jason Wang Cc: Joonsoo Kim Cc: Linus Walleij Cc: Maarten Lankhorst Cc: Mauro Carvalho Chehab Cc: Maxime Ripard Cc: "Michael S . Tsirkin" Cc: Pekka Enberg Cc: Robert Richter Cc: Sumit Semwal Cc: Takashi Iwai Cc: Thomas Zimmermann Cc: Tony Luck Cc: Vlastimil Babka Signed-off-by: Andrew Morton --- sound/core/pcm_lib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/sound/core/pcm_lib.c~alsa-pcm-use-krealloc_array +++ a/sound/core/pcm_lib.c @@ -1129,8 +1129,8 @@ int snd_pcm_hw_rule_add(struct snd_pcm_r if (constrs->rules_num >= constrs->rules_all) { struct snd_pcm_hw_rule *new; unsigned int new_rules = constrs->rules_all + 16; - new = krealloc(constrs->rules, new_rules * sizeof(*c), - GFP_KERNEL); + new = krealloc_array(constrs->rules, new_rules, + sizeof(*c), GFP_KERNEL); if (!new) { va_end(args); return -ENOMEM;