From patchwork Wed Aug 14 12:54:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13763465 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 20197C52D7B for ; Wed, 14 Aug 2024 12:56:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=qcrhu++vGFdPq/ni6Ucoj0gqK+S1YcEKhN4NGqMkP9s=; b=P254yiZvFqnZ47DW3u+Uhfjib+ JuXiaJp/wFjHz/4D1aUpjNSAHROQEvnqc6XFsblcrLGEuhBj4dFWSxpxTUystes2SRNW5fYjZ2NPI ojDDVg8Wnndm0hx9jNZEk5w8iHVsS8E9N8udG4G6i9vVt+mYTaeh/urz8IPvMGWk1MONZR8DtLqCu 22lMAnnnsL3Avf3Ja81O09TPRlNG3UHbQRANjO29mUZv2JsHSpUyQLgleR+jGhDKG7YC99/mVBaWR rey8OxQOVSXa8HmpFJ+ZNXLUdtj8Slc3knZ/K7Paey2yAVSHtJrkqasnASU5QrQDEofDpQOn5Ee0+ NH5vSj2A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seDYK-000000070rh-0z7e; Wed, 14 Aug 2024 12:56:36 +0000 Received: from mgamail.intel.com ([192.198.163.15]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seDX5-000000070Tw-2Ry5 for linux-arm-kernel@lists.infradead.org; Wed, 14 Aug 2024 12:55:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1723640120; x=1755176120; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=APdEsDB4uRUfTA63O96E6T6zEAl1Dq01I03zQVCsNlk=; b=TFxbwEQjj5zsR/JBEs/rm0auWQgGnVUQRWCE7Y22XjOrnYqksz5v1+wr o6y+zdXRp/hCCdnwiDesHh6hDJodmj4ciMyiarMUFHw8t4Ozg7roy9wwt vhr61s/h+6D1YwRWweVcP11WuCyWVnGnXKh0MUn7K0oOUtFSrmzpz2hwj z1Y/r39k4mbL8fVwQdKE1We1dfkJrT7RNwJR2psFfqB5CGX4W1kmWSwGE GvEubVOPdoERPLIJOiJCUg0Lb7XsOiASLIfhKXpYCZba7VERyemkJkMfh exPCQ2FDMWEy38fPRWcjQzA6L1g52evYEWQ+rTFD/K1xw7Mo2979SAXap g==; X-CSE-ConnectionGUID: F4wMWhQlQpSLhCZLiSH1Dg== X-CSE-MsgGUID: 2xVdbFqjSNSE2HAjPM67ig== X-IronPort-AV: E=McAfee;i="6700,10204,11164"; a="22010672" X-IronPort-AV: E=Sophos;i="6.10,145,1719903600"; d="scan'208";a="22010672" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Aug 2024 05:55:17 -0700 X-CSE-ConnectionGUID: tYGueyiRSOmWo/oRDpCZoQ== X-CSE-MsgGUID: WpwGN25MQM+gY6nt7vThPw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,145,1719903600"; d="scan'208";a="89804224" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa001.fm.intel.com with ESMTP; 14 Aug 2024 05:55:15 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id E0C012FB; Wed, 14 Aug 2024 15:55:13 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Michael Turquette , Stephen Boyd , Nobuhiro Iwamatsu Subject: [PATCH v2 2/2] clk: visconti: Switch to use kmemdup_array() Date: Wed, 14 Aug 2024 15:54:08 +0300 Message-ID: <20240814125513.2637955-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240814125513.2637955-1-andriy.shevchenko@linux.intel.com> References: <20240814125513.2637955-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240814_055519_765210_DD33802A X-CRM114-Status: GOOD ( 11.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Let the kmemdup_array() take care about multiplication and possible overflows. Signed-off-by: Andy Shevchenko --- drivers/clk/visconti/pll.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/clk/visconti/pll.c b/drivers/clk/visconti/pll.c index e9cd80e085dc..3f929cf8dd2f 100644 --- a/drivers/clk/visconti/pll.c +++ b/drivers/clk/visconti/pll.c @@ -262,9 +262,9 @@ static struct clk_hw *visconti_register_pll(struct visconti_pll_provider *ctx, for (len = 0; rate_table[len].rate != 0; ) len++; pll->rate_count = len; - pll->rate_table = kmemdup(rate_table, - pll->rate_count * sizeof(struct visconti_pll_rate_table), - GFP_KERNEL); + pll->rate_table = kmemdup_array(rate_table, + pll->rate_count, sizeof(*pll->rate_table), + GFP_KERNEL); WARN(!pll->rate_table, "%s: could not allocate rate table for %s\n", __func__, name); init.ops = &visconti_pll_ops;