Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp487611lqt; Thu, 6 Jun 2024 09:12:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVlWoXhy5PGEZJh5hDd2xzm/8gqmsJO334O590KaILqsQWlAV026vw0nuWgPWpbiliJtBDTD9KeSztI0aI9bMeFH/bdEqyEU7jcw2BY7w== X-Google-Smtp-Source: AGHT+IGBNL9e4eTAILICt3k/quACPs0HPRB1Q9WSD9a/AwhukjxWKJPNp9n38qQ3o19AKibJSp/K X-Received: by 2002:a17:906:1558:b0:a68:a7bd:79b4 with SMTP id a640c23a62f3a-a6cdc0e2633mr491866b.77.1717690351545; Thu, 06 Jun 2024 09:12:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717690351; cv=pass; d=google.com; s=arc-20160816; b=UTdUkKw4nHbeHqhwyzNJOhkuITN5oMUB0+JTFvSKnbE9DRUYGDSS6yMbQs+YyNwwvX OU5ZI/YEb/0dukhFzfy0lzPvnk17SeiOqMMf1tRcUjVwvIUWf0dVmwU8ZDfCSJcO2kV0 t1rsedjPlLCHJD87D1hxFydbl0PtBeAMuK5WR7fkOCf3HGMV+/aUMtQcihLIS/D3r+0u NT3Noq40lxwulDzCe3s4huM7cubcbcUR+Dvc1pfkP6xGx7U5JbhrXowcYTZntPeHCOS6 ikdf6QLujh5CH7FuOsTp9N4oORqaSs8y6TVUgT6jLZvxK6H5vIXZ3MGQVsSlmDwLiJ29 ihKA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=DVNR8g6Fc9JdIXq33j1UoN4hHiofQgeXEK9aIPvtS7M=; fh=/L17KR6uLzrKTac61HyP81Lgj0mZrWjs9Ul61xLMewQ=; b=fld8rtP9zq7+Iua0JwjBv8jBUzwuEI4QJ4XByWKGb3xZJnexdsvEU8smYHuST8OSWG DAhUYl46DNfAI1Sj3VogQcOo5o0c1uH8vGONyLUwXuUE8dgQP1ZLK1DHTNm65woNVlk6 Sdp5Nt/gZXFhQi12xPeYn2oc9FlESC8hRZ/0r1yFeSaYDTxsEqBd1ygGkgN9PbjbBDYO 2oKsPs7/WJL2YH5UYQxyrDmJg5jC6WRpBs7q/hB8lF2LioHxZR3Jryxr9OchE1HrIBzk jFLFCo3gZb8CfhLzU+6yWhzjA8fqUaC09vcIrmQsyJhEldHgiwSjijkjOf1vE+1ZM9Af 1t8A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lIL9SuzP; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-204656-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204656-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6c8070656esi75943266b.527.2024.06.06.09.12.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 09:12:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-204656-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lIL9SuzP; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-204656-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204656-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 4615A1F23F13 for ; Thu, 6 Jun 2024 16:12:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BB8F5199225; Thu, 6 Jun 2024 16:10:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="lIL9SuzP" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 878DA1991B6; Thu, 6 Jun 2024 16:10:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717690239; cv=none; b=IF19vK12HVd7m6yJLsGD5XZ7JfYTPxxRVe/P+PPXMj93nIAQz7WJ2ZH+Yb6z1UdTBik1uIIt3rSneTENipBZ+Y54FUaixo6H8q/PZPGp7SXH+znIvqEHHzEkTy477HWizkbbEepw4wPD3ZeTMGh9BHyyhvhOzYZmqOFbYNaoCRA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717690239; c=relaxed/simple; bh=981GD+z8786+C1hp7EEXk+A3A1FHkVkYoLEaJHuT4kc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T5kzeRBt/B/hzzBtQcdvdu9i2xA7jt8BRe3dpM/DPKGEaJPPKQuxP2cLVl6k9RzFzPXgNm2Oe+UBYvqOy7hgZ66wqcjfUuFf1kgHR+pjcJD1JcHDKPsk4d8g0XsHArDY1GqryAd3LXXyjS+HYhuodUHFACNbbGnYFhPDk/sSZIk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=lIL9SuzP; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717690238; x=1749226238; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=981GD+z8786+C1hp7EEXk+A3A1FHkVkYoLEaJHuT4kc=; b=lIL9SuzP05E736w2t6sclJvu3JqLstKrWkKBJ/zTYz2Sr4IkcQv/5lJD FbHS8TuKdGkelpaIeuPt9+y7fzkv40lYjRMv/vzXotl1pdgOr0NzFIx58 ksQzp4nq9h7NsMk2DrEITP4Knd/hNmuRZhZPD4Stu7FKCagqpv7jfeeun arpxMsNWizX0ycsv7QMm8ANfUFwhmnXd7lTj8JL1/GFtXHxGd2tlO5E0L n4e9KKB662q9eTojfVIj2tYSao/S2qF1tcg4vagZZj+B0O7168+WB5C38 Vy9hyXy75VGDpXMb5w46MgfDOt0IJAER1gAU7e4FepHULRnEG+uG0NXIT A==; X-CSE-ConnectionGUID: N/xwbN3pRw2XyKatPQvEGQ== X-CSE-MsgGUID: bAVsWFH5SxqrIc3Sye+W3g== X-IronPort-AV: E=McAfee;i="6600,9927,11095"; a="14525065" X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="14525065" 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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; -- 2.43.0.rc1.1336.g36b5255a03ac