Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp640212lqt; Thu, 6 Jun 2024 13:51:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUJhqgor/doVGR1vyPhcid+6UpUpm6X/IyXIP/mUZIHouKj940zddwVlGLcl/ih04KHSTzqOI+Pu6TBVURHgQYSMFsve/kf0ToW+lr+2g== X-Google-Smtp-Source: AGHT+IG1VM8gBcoKIebaQmhjwHvtM1LfbRYwIHSrS8B/h6QAtZxnA9baRt42+wVJJlpjaztTy3a4 X-Received: by 2002:a17:90a:17c6:b0:2c1:aaad:e5a8 with SMTP id 98e67ed59e1d1-2c2bcaef040mr726714a91.21.1717707113819; Thu, 06 Jun 2024 13:51:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717707113; cv=pass; d=google.com; s=arc-20160816; b=tk2kwFaAyPYgOv4gQ4flll5gkOzA1rz4zqeoulv11W1qaspk2OygyWAZhqW3H1QOC/ h5tG4SxMJJlqMnMGfbE35z3K4PYs4MWTb9Gj3n+FIwSGEbHE2AyAPW2+bkPbrk5H6dTD 4y5siXji8Rh90/zD1D8BEYcarjMEBlvCzh/6U1zvVTxHLIK6q+9P+N7WzmKijdiYzsAu GOL8tqnHK+6ZIJxkTt/mBNwDrg6H9z41I1Tm981FuOvxbP9DY3W5FA1VS82vSwLPOngM bmagBOTdJaYfLwkp32OI0J8uk1H1jufskEOfRjFk67kyjP/5UXULqgNY2VszmgoymLiB UxlQ== 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=pZeXDwMJiGcgBaNNzeRYADJ1rUwa615VOo3im3WWVgk=; fh=LXM2gf4d9oA1yzL5Xz3NxBybf1HFCTWlglrC0puI/CI=; b=xSlE8SoilyCszSfqKkbDkR1n6Xkfo+o0/xbTCCI7q5NCcC8MdFm0R2Y7EAH0Jsfz2y BXXRNwWlBE7ywQ8keKkwXmNqF6tIbpxDLbUzY4E5Or+M4R5rs0e1Y1J+fWAU/wSdOEzc JwtEJfFoy62X0hQkmKMc5cwPAk95oMAuTwQAaZIadiUxNjrEHMFFskwfYHLibuCLB/wx UDbkNmLKO45OLRKpTjU3hHKE4fAleOXZW3E6mKgK3p4lKqM2ruinZr52Dj3oD9ixoGfP tPTwpVB55FMHb1jkFKxvpWuxmukNyf6wAJ4dbe7gyNTD77aQ2nVrW4LBggFx0FY6wncr PqpQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UNIkGz+4; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-204725-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204725-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c254a7a862si4862786a91.0.2024.06.06.13.51.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 13:51:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-204725-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UNIkGz+4; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-204725-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204725-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id AE55CB2BED5 for ; Thu, 6 Jun 2024 16:48:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 835ED1991B1; Thu, 6 Jun 2024 16:47:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="UNIkGz+4" 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 0BB00198E70 for ; Thu, 6 Jun 2024 16:47:24 +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=1717692446; cv=none; b=PHYT/11A8cNp3IAQYToEbsG/V4xbziksf1z3ej1/UKWuy2Ka+ejhb3HxQ/yslweuusNo0QAgFC/RDACjdxHrcHW0E/oz4lX1mf+JS4/37KQZlJblxNbSXW69aUQ3Zee8EAqAiz1ze473v9s8fxZiD5yz2WnQAdo7I6CzGVWG3rU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717692446; c=relaxed/simple; bh=T6gLK4Xhn6yVmKQMI4ularKMV+lLmcOSTs0tDmhhchQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V+YogUPlVPaiwVXGMW2J4hoGbgMmMusDXuTbr7gLkcAD1nP/3uMVvVlcyGMjxo8nzmTP8eTYP9YnmzZaWlp2buPkJRKxsH0NpiVT6psdv/1weFUYTvldBZ/CJdh7VEI8GZQEAi3Gv4RH1yaZUkJ4hc42KP+HPEkb5tWYHcVYWq0= 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=UNIkGz+4; 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=1717692445; x=1749228445; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=T6gLK4Xhn6yVmKQMI4ularKMV+lLmcOSTs0tDmhhchQ=; b=UNIkGz+4gUcEfTLqMC70xLllwPhZewW/AWrDVfbhCeyVsGcVKllgs04T ExFgptU3kmaec94EXELQl25cFko+jZjykINQBPIWyFtDa0KYEYeyCQWQL 5FInGefVr0U/InV9tdKLB2LQau16rf8+56W5zdqWhmvZAr/VK+wkrcQ+g eHRqmeLR0GY+Q2g1O833hc/luIKvOpeAgZWQoXlYZXr3ijUCsLI6twB/U NMRHxktcqQhe1Q+NvyFuEeNG74HE2CmhBQaGaQFiCTwYOFlxHQmsM/ckk CiwP2U9b7ClJRngqvfM25hOko2wDVX2UUA6ZXGzGVUjNSPuPN8+hVKziQ g==; X-CSE-ConnectionGUID: PEe7vukoSM6CSw0+R7CyCw== X-CSE-MsgGUID: xxJZHO0gQnKu6nCWuEbgpw== X-IronPort-AV: E=McAfee;i="6600,9927,11095"; a="14531942" X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="14531942" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2024 09:47:21 -0700 X-CSE-ConnectionGUID: kPBrPhZJQBq/JOJdCyogdA== X-CSE-MsgGUID: c1BP5ct6QlSic9YG4VK5/g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="38475879" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa006.jf.intel.com with ESMTP; 06 Jun 2024 09:47:20 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id DBCC52CF; Thu, 06 Jun 2024 19:47:18 +0300 (EEST) From: Andy Shevchenko To: Mark Brown , Andy Shevchenko , linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" Subject: [PATCH v1 4/4] regmap: maple: Switch to use kmemdup_array() Date: Thu, 6 Jun 2024 19:46:25 +0300 Message-ID: <20240606164717.3031107-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240606164717.3031107-1-andriy.shevchenko@linux.intel.com> References: <20240606164717.3031107-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/base/regmap/regcache-maple.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/base/regmap/regcache-maple.c b/drivers/base/regmap/regcache-maple.c index e42433404854..f0df2da6d522 100644 --- a/drivers/base/regmap/regcache-maple.c +++ b/drivers/base/regmap/regcache-maple.c @@ -132,9 +132,9 @@ static int regcache_maple_drop(struct regmap *map, unsigned int min, lower_index = mas.index; lower_last = min -1; - lower = kmemdup(entry, ((min - mas.index) * - sizeof(unsigned long)), - map->alloc_flags); + lower = kmemdup_array(entry, + min - mas.index, sizeof(*lower), + map->alloc_flags); if (!lower) { ret = -ENOMEM; goto out_unlocked; @@ -145,10 +145,9 @@ static int regcache_maple_drop(struct regmap *map, unsigned int min, upper_index = max + 1; upper_last = mas.last; - upper = kmemdup(&entry[max - mas.index + 1], - ((mas.last - max) * - sizeof(unsigned long)), - map->alloc_flags); + upper = kmemdup_array(&entry[max - mas.index + 1], + mas.last - max, sizeof(*upper), + map->alloc_flags); if (!upper) { ret = -ENOMEM; goto out_unlocked; -- 2.43.0.rc1.1336.g36b5255a03ac