From patchwork Thu Jun 6 16:09:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13688732 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 C5767C27C54 for ; Thu, 6 Jun 2024 16:10:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6EYaFWXeS6TlziNzrgYTf+YgZF8H7OseMtN+th9iMn4=; b=0AbaN1xV520aHR GPQ2p2uWsu5U6XK54ZnwPSIIB4gk8/uAfLblYbbCvAgc6yolz+R82Xz+10nlWCCHwYHkloONXqWvv 2zSOBphzL3oOCPLPEN3jnFbs20OZmJ7c6g48BAA5p+/PpXtzrS9Zth+gQ0bbmcMGxBFlS+jQICgB9 m+AOdhnt27puebEJtwZNoBAJAJBZ6j6d2guXMkB52MPqxEpm0DeVFxOEVxNEpMYYu0LKSy6cUZYYe XdF9JAjD961rIvzdI2vY7NOBxjB02mfSqR0NJaikSpmshoJarX3dCpNzvR4zeAWSdJPptRqBKjn4x YNCwHoDoLrUCeu+juitQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sFFhJ-0000000AR9f-1aCX; Thu, 06 Jun 2024 16:10:41 +0000 Received: from mgamail.intel.com ([198.175.65.18]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sFFhG-0000000AR8P-0IOH; Thu, 06 Jun 2024 16:10:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717690239; x=1749226239; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=981GD+z8786+C1hp7EEXk+A3A1FHkVkYoLEaJHuT4kc=; b=BW+DiMATlaMpkalJLBizAh/FGvXnX5R4rQlW5M0Vi2bsOFO8uvahE0tx snJH16CGPMSVukcY+s/BT5PhQl32MRBNOddk/ppPUm3ExZ4OQDYrJl71d 3M/z5sANR5A6LxQpotSBo4fj+1uN+kDWwT+hlsGkWycQSKHZkIiuXqK2O Pm/9vAgITFylHMlculUWMNLVmEnlWMt/keSdoZcHwm0l4iLl48mxSU/u9 0XVHxcI8v7sYTlYx4ozuob7sRaQG2zy5aOTt/EOX+uVn0Adlf1bWevhkU 4md8a/nyE3bxD1D+hwhJxH+VzczmiGcycDm7/FbSLDSmI6hXdUXDgx3+Q A==; X-CSE-ConnectionGUID: OKBfSsCfRq2HmdkT9aW1Jg== X-CSE-MsgGUID: hH5sJbxZQ2W+F/Mt4w0uSw== X-IronPort-AV: E=McAfee;i="6600,9927,11095"; a="14525062" X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="14525062" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2024 09:10:36 -0700 X-CSE-ConnectionGUID: 0YfWCvGIRxmFQhBgzuOM0Q== X-CSE-MsgGUID: fP3DNq1eQYaIJNdR5+FS1w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="38695663" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa007.jf.intel.com with ESMTP; 06 Jun 2024 09:10:32 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 617131C9; Thu, 06 Jun 2024 19:10:30 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Sam Protsenko , Krzysztof Kozlowski , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org Cc: Michael Turquette , Stephen Boyd , Heiko Stuebner , Krzysztof Kozlowski , Sylwester Nawrocki , Chanwoo Choi , Alim Akhtar , Nobuhiro Iwamatsu Subject: [PATCH v1 1/4] clk: mmp: Switch to use kmemdup_array() Date: Thu, 6 Jun 2024 19:09:31 +0300 Message-ID: <20240606161028.2986587-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240606161028.2986587-1-andriy.shevchenko@linux.intel.com> References: <20240606161028.2986587-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-20240606_091038_174479_59112D3C X-CRM114-Status: GOOD ( 11.29 ) 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 kememdup_array() take care about multiplication and possible overflows. Signed-off-by: Andy Shevchenko --- drivers/clk/mmp/clk-mix.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/clk/mmp/clk-mix.c b/drivers/clk/mmp/clk-mix.c index 454d131f475e..07ac9e6937e5 100644 --- a/drivers/clk/mmp/clk-mix.c +++ b/drivers/clk/mmp/clk-mix.c @@ -447,7 +447,6 @@ struct clk *mmp_clk_register_mix(struct device *dev, struct mmp_clk_mix *mix; struct clk *clk; struct clk_init_data init; - size_t table_bytes; mix = kzalloc(sizeof(*mix), GFP_KERNEL); if (!mix) @@ -461,8 +460,8 @@ struct clk *mmp_clk_register_mix(struct device *dev, memcpy(&mix->reg_info, &config->reg_info, sizeof(config->reg_info)); if (config->table) { - table_bytes = sizeof(*config->table) * config->table_size; - mix->table = kmemdup(config->table, table_bytes, GFP_KERNEL); + mix->table = kmemdup_array(config->table, config->table_size, + sizeof(*mix->table), GFP_KERNEL); if (!mix->table) goto free_mix; @@ -470,9 +469,8 @@ struct clk *mmp_clk_register_mix(struct device *dev, } if (config->mux_table) { - table_bytes = sizeof(u32) * num_parents; - mix->mux_table = kmemdup(config->mux_table, table_bytes, - GFP_KERNEL); + mix->mux_table = kmemdup_array(config->mux_table, num_parents, + sizeof(*mix->mux_table), GFP_KERNEL); if (!mix->mux_table) { kfree(mix->table); goto free_mix; From patchwork Thu Jun 6 16:09:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13688734 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 B62B9C27C54 for ; Thu, 6 Jun 2024 16:11:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ZPdyFiFD+49WcbLayIvQJdIH9xOrUQgySpVezFHOdWU=; b=Za5A95FPd0WsCr fKRwlQZ8VO06TQqlqrpj8qRmy3kdiidNt+qKfKDOOxmBc2u5dpGvB6HAlrDbGQkp6UKEr7nb66Vuq aQRmQIALCXb7N+PTYGF2nGlUABNzfIqgS/J/aDRWehdk3MLJFR7eL02FUEGitYmr+my3s3iDwN2HJ vwN6JCIgsOUmIPLtA8gOVwbpT6UgKE9HETVMP7SzD9KoyurVSU/1ah/4gfwcpPET6DPGWvlF/ZGex BxUabWQ5b6x6mJbby1sawpx09vULkUp4jeYP169QSBjyA2qKKAUeRUiZATQY98srtP4tQxfgD9dU9 caMIQTrEBL/66M9m+z3A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sFFhR-0000000ARFW-16s3; Thu, 06 Jun 2024 16:10:49 +0000 Received: from mgamail.intel.com ([198.175.65.18]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sFFhJ-0000000AR8P-38Pp; Thu, 06 Jun 2024 16:10:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717690242; x=1749226242; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gj6vGOfIMvi9wknlVIRBepDS/CXPzi91odpfx0mTouo=; b=SJ2Sj9Phze6N0SA/HRjzuQT5gURLl2j+fAkdgDjbsbxnuu587oswR5/r aqciAhlIWA4k8uhjqRD7WyyTVRUWC0A/GIeb5fAaU8qEZGvJNoIbjQq9G prFQkhz2tLZ54VJZLQ2bCgD8Qtda2+paBlc4kKbcD1vpuYnwkZrUDf8Wu WUYQ9b+SiJTLbc1Sk9OLHtInYzTwpfWrBqOyWBdAeSvN3olBtcMD6Hhsn X3rCQv5dxJJ2aV6nHE+O0pPbAoQQKOpA3cYc/LoFmo9oYbbECx5pQt+5W c69xBVzfj84/APpm6f6SjryNxW7XoMM+uYMkJ0VWES6A4hLwBJiXckFG8 A==; X-CSE-ConnectionGUID: Lg2ocr2rS7uGywx7Y4Mv/g== X-CSE-MsgGUID: iO3k/i9jSyWj6jAG9cDxfQ== X-IronPort-AV: E=McAfee;i="6600,9927,11095"; a="14525079" X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="14525079" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2024 09:10:36 -0700 X-CSE-ConnectionGUID: 6qzv+wlwTLqiO2jXs6ZH2w== X-CSE-MsgGUID: WntpOTQdS1WOSgQljWuITw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="38695664" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa007.jf.intel.com with ESMTP; 06 Jun 2024 09:10:32 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 68B992CF; Thu, 06 Jun 2024 19:10:30 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Sam Protsenko , Krzysztof Kozlowski , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org Cc: Michael Turquette , Stephen Boyd , Heiko Stuebner , Krzysztof Kozlowski , Sylwester Nawrocki , Chanwoo Choi , Alim Akhtar , Nobuhiro Iwamatsu Subject: [PATCH v1 2/4] clk: rockchip: Switch to use kmemdup_array() Date: Thu, 6 Jun 2024 19:09:32 +0300 Message-ID: <20240606161028.2986587-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240606161028.2986587-1-andriy.shevchenko@linux.intel.com> References: <20240606161028.2986587-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-20240606_091041_952948_1725244C X-CRM114-Status: GOOD ( 11.83 ) 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 kememdup_array() take care about multiplication and possible overflows. Signed-off-by: Andy Shevchenko --- drivers/clk/rockchip/clk-cpu.c | 5 ++--- drivers/clk/rockchip/clk-pll.c | 8 ++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/clk/rockchip/clk-cpu.c b/drivers/clk/rockchip/clk-cpu.c index 6ea7fba9f9e5..398a226ad34e 100644 --- a/drivers/clk/rockchip/clk-cpu.c +++ b/drivers/clk/rockchip/clk-cpu.c @@ -369,9 +369,8 @@ struct clk *rockchip_clk_register_cpuclk(const char *name, if (nrates > 0) { cpuclk->rate_count = nrates; - cpuclk->rate_table = kmemdup(rates, - sizeof(*rates) * nrates, - GFP_KERNEL); + cpuclk->rate_table = kmemdup_array(rates, nrates, sizeof(*rates), + GFP_KERNEL); if (!cpuclk->rate_table) { ret = -ENOMEM; goto unregister_notifier; diff --git a/drivers/clk/rockchip/clk-pll.c b/drivers/clk/rockchip/clk-pll.c index 2d42eb628926..606ce5458f54 100644 --- a/drivers/clk/rockchip/clk-pll.c +++ b/drivers/clk/rockchip/clk-pll.c @@ -1136,10 +1136,10 @@ struct clk *rockchip_clk_register_pll(struct rockchip_clk_provider *ctx, len++; pll->rate_count = len; - pll->rate_table = kmemdup(rate_table, - pll->rate_count * - sizeof(struct rockchip_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); From patchwork Thu Jun 6 16:09:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13688736 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 41525C27C54 for ; Thu, 6 Jun 2024 16:11:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HvgPxII0QHoFTjyH0rr86JHFkSp6FQTQDQK8vL98sFc=; b=nP2qWw2uhh+NVd QITE3/D2FtlDBdb/3B0N3ml4O9bZ9CN0c8nkbu8hM5Extouu4gS1T1nVjJ7NON+N1zKWly3AC2l+I M4fziXJgiu1aJ0AoYY7xsVSFFsKMAvvGBl+WSWu2x+IW4yOoPYqQPYLEnw9lvo8xG+1+442Gz4TYZ NUm/QJ7LmR3mgcN1nBHFwMNN70P5H0DYLQ49CpRs3mbnmDmSSDMysrhMzJzL5Zd2vVXtNX2xvYjDv Bd59Ybtgt3GTDTztqcVMt5GF3d+N38cfw+e6cIkxWPmrLR9+RSwRkWNnmaeiwF5HUZSuXOYiyExL1 RJU4j2N3gUZooYaHoecQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sFFhU-0000000ARHq-0SvQ; Thu, 06 Jun 2024 16:10:52 +0000 Received: from mgamail.intel.com ([198.175.65.15]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sFFhK-0000000AR9o-3QC6; Thu, 06 Jun 2024 16:10:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717690243; x=1749226243; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3+qSRLVpcdMyUzcNy5jn6Wrz5bikHflvBafSsMgGFj4=; b=XbX52wChUHaiCM7SA3s8XqMzu3KX57Fdn2ez3VOsLodvGgqvMw1FnCVh 4P/e1Fn34ff3mzQdNyfKblZrAObkOfyVMKCiy+byfE64or+WSZPPNx2T7 ahohULxD4ioiB4xgB1mShTrzgJDFJusWg4wf+QcLJQbq/1RSJ2BaajLT7 qAOUXlWtU2mczKaMrplWU6gHSh448HTiQPTKGRud+//ZSITOuUxvDTRQa noO3RIH8aouFMMgFA9Io0/MlyDJN63Kggkg1bKdobfguhWkQtyUf//OiC 1lfKzgJqIEACPdZD2EeclhHNhTqVnnOuxMz7OTpfmkzA6NGI9oVk4wkzc w==; X-CSE-ConnectionGUID: Pe+36RZVTwuLF81nhgwwPQ== X-CSE-MsgGUID: bjMA6q7NTH+2/TeRilhi+Q== X-IronPort-AV: E=McAfee;i="6600,9927,11095"; a="18164349" X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="18164349" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2024 09:10:35 -0700 X-CSE-ConnectionGUID: 6PYiMqvtSKGU11AqT+idoA== X-CSE-MsgGUID: nCNrCDJvSL+zXHFUY5b1DQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="37949163" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa010.jf.intel.com with ESMTP; 06 Jun 2024 09:10:32 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 73307339; Thu, 06 Jun 2024 19:10:30 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Sam Protsenko , Krzysztof Kozlowski , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org Cc: Michael Turquette , Stephen Boyd , Heiko Stuebner , Krzysztof Kozlowski , Sylwester Nawrocki , Chanwoo Choi , Alim Akhtar , Nobuhiro Iwamatsu Subject: [PATCH v1 3/4] clk: samsung: Switch to use kmemdup_array() Date: Thu, 6 Jun 2024 19:09:33 +0300 Message-ID: <20240606161028.2986587-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240606161028.2986587-1-andriy.shevchenko@linux.intel.com> References: <20240606161028.2986587-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-20240606_091042_998054_BD074CF2 X-CRM114-Status: GOOD ( 13.40 ) 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 kememdup_array() take care about multiplication and possible overflows. Signed-off-by: Andy Shevchenko --- drivers/clk/samsung/clk-cpu.c | 4 ++-- drivers/clk/samsung/clk-pll.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/clk/samsung/clk-cpu.c b/drivers/clk/samsung/clk-cpu.c index fbf4c4208e06..dfa149e648aa 100644 --- a/drivers/clk/samsung/clk-cpu.c +++ b/drivers/clk/samsung/clk-cpu.c @@ -689,8 +689,8 @@ static int __init exynos_register_cpu_clock(struct samsung_clk_provider *ctx, for (num_cfgs = 0; clk_data->cfg[num_cfgs].prate != 0; ) num_cfgs++; - cpuclk->cfg = kmemdup(clk_data->cfg, sizeof(*clk_data->cfg) * num_cfgs, - GFP_KERNEL); + cpuclk->cfg = kmemdup_array(clk_data->cfg, num_cfgs, sizeof(*cpuclk->cfg), + GFP_KERNEL); if (!cpuclk->cfg) { ret = -ENOMEM; goto unregister_clk_nb; diff --git a/drivers/clk/samsung/clk-pll.c b/drivers/clk/samsung/clk-pll.c index 4bbdf5e91650..4be879ab917e 100644 --- a/drivers/clk/samsung/clk-pll.c +++ b/drivers/clk/samsung/clk-pll.c @@ -1286,10 +1286,10 @@ static void __init _samsung_clk_register_pll(struct samsung_clk_provider *ctx, len++; pll->rate_count = len; - pll->rate_table = kmemdup(pll_clk->rate_table, - pll->rate_count * - sizeof(struct samsung_pll_rate_table), - GFP_KERNEL); + pll->rate_table = kmemdup_array(pll_clk->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__, pll_clk->name); From patchwork Thu Jun 6 16:09:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13688735 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 BC98DC27C5F for ; Thu, 6 Jun 2024 16:11:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bDo516/gqegHyhOpmTNj18CjpVoc7yd25J+Gr1bRUM0=; b=Va+rQHJtYjGYj5 mMX4b49EDxdb/fryQUUadSmLviuqIm8ukioCMwC3Gy8gFn2P/BfQpC08/o/dEcL+TMkN99L73afpc kykjTHMPSpdjIxeG9iRszaaLTsT6nleLpYFB8cFLhYT0QfueVz9f0qwKsBHcQAzLNsVrotf7vbYi7 i6LcgJng9BvNeiI6n+R50NFP6wUDLja+ebaVGyfEG2wKiJArqTjS+oegXXjTZuavXtnGt/3NuSkBb lhel3nWyWscfq3hJ2NttlMfKT1RxxlAwySnzLYfoBOtX3ivSE0m9iUH1pTJUAAS6naLrlzPGDdY4w 0N5iRy3TIpkumU+8R3yQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sFFhP-0000000AREC-2l3S; Thu, 06 Jun 2024 16:10:47 +0000 Received: from mgamail.intel.com ([198.175.65.18]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sFFhI-0000000AR8s-1qXP; Thu, 06 Jun 2024 16:10:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717690241; x=1749226241; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xWWZ+gaYkDL6L7se9sOsqYkVgD6gieTPbfInOylbZ7E=; b=LaRrU1XRTDoiPBSe3+605r9GAiMSaAbV91tVFuxQ9WBDMiCh5Xo/hlNa C2yjtvPHebTAuChVnPgT6baI3nvA5FLhiERkmOGdzzNmcHXs33nIJCJdd iQRkjdSS+NcThYjkCJY4/k0wpFrIOT53P+IDTflTJmaKkyt9RKPT1uzdv L6wpVaQhtzIU/1/3/idXIOMY7XcIKoD7jGcZR2e8QRxhOTn2/cYO5tn/Q akgyWXdSAAxvwbl2OguMSndS/L1sd/PrsqlpwB86lixYJ4AdlwkpK14fn fAtaXwJn5RGRV5IwARO6LQFYoJZlYs6O/nAC8GqpehtuY9CmCxpABMM75 A==; X-CSE-ConnectionGUID: L8GaPXpgQKqYj1du2xIiiQ== X-CSE-MsgGUID: YMgvChj3SYqmkNhIp/2TLw== X-IronPort-AV: E=McAfee;i="6600,9927,11095"; a="14525087" X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="14525087" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2024 09:10:36 -0700 X-CSE-ConnectionGUID: d7XDmZzjTU2ZhgGmzyFAEg== X-CSE-MsgGUID: z077FzzDS26beD27llOV4w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="38695667" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa007.jf.intel.com with ESMTP; 06 Jun 2024 09:10:32 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 7F778371; Thu, 06 Jun 2024 19:10:30 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Sam Protsenko , Krzysztof Kozlowski , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org Cc: Michael Turquette , Stephen Boyd , Heiko Stuebner , Krzysztof Kozlowski , Sylwester Nawrocki , Chanwoo Choi , Alim Akhtar , Nobuhiro Iwamatsu Subject: [PATCH v1 4/4] clk: visconti: Switch to use kmemdup_array() Date: Thu, 6 Jun 2024 19:09:34 +0300 Message-ID: <20240606161028.2986587-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240606161028.2986587-1-andriy.shevchenko@linux.intel.com> References: <20240606161028.2986587-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-20240606_091040_601195_A23868B6 X-CRM114-Status: GOOD ( 11.44 ) 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 kememdup_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;