From nobody Thu Feb 12 21:49:29 2026 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 87B33198A16 for ; Thu, 6 Jun 2024 16:47:23 +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=1717692444; cv=none; b=Wj+U3Vv1zPmEdLq0+2AKXnwkIRnAaxPFt798xEFKitZ+hGTVeohZFO3yH5+ix+tRVMKNfmbi9sdesVHQcpLnyZfVsLLVzdEJsQr3U1GPq19p4Af2YBnLnr0JZFQ7JiGjkCq9l9Yd3bar7DdsD+Vj7feIj59xm5MLY+b7V0/oiLc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717692444; c=relaxed/simple; bh=EHAguvGTDCaazxEec7Y5c7L9Y24xpgClBLYrG0xPN+k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QIc1ffXO+M2X2u/Y7Ml+NUa6wEqWDpRfWTR6xLb85YqFuC4Ly3rBbcvgvgJFafJSJ75eFF8l2k/9rbpxlpBqvdKT19F3eIJ3wBqR4kndBmKn1qwC5+wTV2Lv2KVZWcELpQVN6zHbQtQwOZtEVmrt+cM1lLZNvvizddS6NI29SG8= 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=TtF2O/A4; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="TtF2O/A4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717692444; x=1749228444; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EHAguvGTDCaazxEec7Y5c7L9Y24xpgClBLYrG0xPN+k=; b=TtF2O/A4YLzlmX4N85nl/0NZ1ampcCsS9DcJhqrkaCUztcjtU9RNpMsN MR5aqBjD8Y3bdcrLW0Rq2Ephirp7c25urZ0OpK+rjRAryZJWCbFEp3y0r GnJUt90dcLKxva4IUeOdmiG+b62DAige3aJbqWuyKMWtqCIM58RzdljaJ TLdjJyrO/d4AwsI0B/QcD5L57JNUYRLKInrcd/UzCfiK8ZfJRXwVPovF2 gOAJXTEGg6cG/xywwqAr/DEDtPnnXxP5KlUo58g3CCMXwy3Jd5OxI5AFN i+twgDQtCAVOQ0ZA29COTyFITvCuT7WtUZtJpKHCY+dyANWQo6wyZWLQ4 A==; X-CSE-ConnectionGUID: Fw+TYToASoy2DQlzYfRlBQ== X-CSE-MsgGUID: 9fBgO9Q5QEeLaSfeZDdEzA== X-IronPort-AV: E=McAfee;i="6600,9927,11095"; a="14531937" X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="14531937" 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: PbcrPNtRS0+QLHOHEzBWOg== X-CSE-MsgGUID: asaEZJvDRUSvP3Iy+e6qaQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="38475876" 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 AEB871C9; 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 1/4] regmap: Switch to use kmemdup_array() Date: Thu, 6 Jun 2024 19:46:22 +0300 Message-ID: <20240606164717.3031107-2-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: quoted-printable Content-Type: text/plain; charset="utf-8" Let the kememdup_array() take care about multiplication and possible overflows. Signed-off-by: Andy Shevchenko --- drivers/base/regmap/regmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 0a34dd3c4f38..88c02b71b2ee 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -2347,7 +2347,7 @@ int regmap_bulk_write(struct regmap *map, unsigned in= t reg, const void *val, } else { void *wval; =20 - wval =3D kmemdup(val, val_count * val_bytes, map->alloc_flags); + wval =3D kmemdup_array(val, val_count, val_bytes, map->alloc_flags); if (!wval) return -ENOMEM; =20 --=20 2.43.0.rc1.1336.g36b5255a03ac From nobody Thu Feb 12 21:49:29 2026 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 9742B1E87F for ; Thu, 6 Jun 2024 16:47:21 +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=1717692443; cv=none; b=ZMiaeKMSywAtspJBMSBP9mm7M3E4Z2UTlGB+CO2+CjEKY5ccqquWGyqFpF+Fdmjx3tPuc5W1U6yIXqDu4Xy8TS/4l7jWQ2t+uczlHluksHECUS39DmRIA8Iz35oLk3ipcQRq76K7GjQRUTsnLewphJYnzAcgl+2YuCBKYZbkjO4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717692443; c=relaxed/simple; bh=QOAYhbWy+rWNPn1bB0ti3pyRKF4a9LVOkArl7dVvMrE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oHN7sK9h8Moy462cIh2dEcXlqWsmFjaxco4JqRdk1Mx9vLQoMJ7nZIQUBoMGUgnnvGIzKLstC9Tehl9Te8O/rOrSXmx9DD258bMiYnz+W4dxvzF7ExMbVsYzzUFbcT0zdoC8BSqwtEy6AbD2YzKj1j8GeM8tGmonBHuQMHc76Zk= 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=LCZC9HVD; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="LCZC9HVD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717692442; x=1749228442; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QOAYhbWy+rWNPn1bB0ti3pyRKF4a9LVOkArl7dVvMrE=; b=LCZC9HVDnGhrUdaFkiMbxnZWufIHJOaSQ0FmsObRnRB3DiAc/twl13X7 OkZ87pSTLviATQb4Kp+KXCYSsx7UwwQ8SRSV+Dx6nFtvI/qln0TEzTpGE J20kjTfk+5aesmgP7HEwxcbwey+4DjtBv7chqI5ab0DMS2YFeIOfB3tl0 jOf7rq0NazBJkLKd5bPxHYXVD+iBRDHtX7KwlHXIEiO2YV1/gGooES4Zi hzcyW6TK/FFYF2MHCclkEhcTHIrw5u690iQQdrLxNecTv9ACUeLDRhBFT lKw0wi3K6izt8LWbxmCe0ftnTLbuemP2IvQhdDijMkX0JjO/N0XPwW1mr A==; X-CSE-ConnectionGUID: THGdlaDVRze84W+87PZxYQ== X-CSE-MsgGUID: le8N7KY9TbewEPsEYkzhOA== X-IronPort-AV: E=McAfee;i="6600,9927,11095"; a="14531932" X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="14531932" 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: xb1b+ml5RkedEVogHf1Urw== X-CSE-MsgGUID: ZEHpW6pORb6gNozoa6dawQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="38475874" 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 C2DFD30B; 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 2/4] regmap: cache: Use correct type of the rb_for_each() parameter Date: Thu, 6 Jun 2024 19:46:23 +0300 Message-ID: <20240606164717.3031107-3-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: quoted-printable Content-Type: text/plain; charset="utf-8" Compiler is not happy: regcache.c:410:9: warning: Using plain integer as NULL pointer Replace integer 0 by NULL. Signed-off-by: Andy Shevchenko --- drivers/base/regmap/regcache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c index 2e41cb12b8e2..bd7462c54271 100644 --- a/drivers/base/regmap/regcache.c +++ b/drivers/base/regmap/regcache.c @@ -407,7 +407,7 @@ int regcache_sync(struct regmap *map) * have gone out of sync, force writes of all the paging * registers. */ - rb_for_each(node, 0, &map->range_tree, rbtree_all) { + rb_for_each(node, NULL, &map->range_tree, rbtree_all) { struct regmap_range_node *this =3D rb_entry(node, struct regmap_range_node, node); =20 --=20 2.43.0.rc1.1336.g36b5255a03ac From nobody Thu Feb 12 21:49:29 2026 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 5401E197A7F for ; Thu, 6 Jun 2024 16:47:23 +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=1717692444; cv=none; b=P23BcogVzXX2qmbnQGGnNnwWNVxksldlywsYJbHd6r5sVVNFrQR5q7GGz89/bvKxLPd0E0dzKwaH6OhwRDHAT7+midbkj779pI/V+fEen5RM8kNoYAKzz7pTfj+zLb/QSHLBAOYtS0DhTiCRaFvHMAxJf8Hv9qabKYgA+4jUo4Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717692444; c=relaxed/simple; bh=r+kfSuHjOqr17WFaqvO8+4gnvADH+fS1GXIF7AYuo5c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IW/Uuq2hWjF6r9eaya8J7Kr8cqCIhKky7IB1b9pQO/USrxpGBvuPty6LcaeotxcJfjCSTGOtDx8mw73RLZEVB2cGWFQTlYd5As0lld25fKxBUVPdvEQ06DBZparJLLD4jhuKmstojtMsRNWeOluXUoHitLRKlY9PuZ7O3uU3TCg= 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=GbIjW9Dl; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="GbIjW9Dl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717692443; x=1749228443; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=r+kfSuHjOqr17WFaqvO8+4gnvADH+fS1GXIF7AYuo5c=; b=GbIjW9DlLs4oe979TFLfNWeP4quY0rPW3UGsvhyMUqdj308c7vBstBK/ ZPr9iL3LbXmytGo/dh9sI9xlsYUWudSa9HcuP1L5Pmzj6oO5qeGRfbhYg fJOBM1wVGCdDwwPbcmgithLlLZBD8GBxrU3ntCRW30VrLMhvl8/0ih0xO njUwCJ4Wn/Jb7V4ghz8kerj1Zr6iX6jZWTzu29JBsEL8nh+4ZVQ+js29Y qmR7tMZnyk9Ev1+4AR/Y5tw7STMVAyj/JFmHJOvGcBLDLe9fyXje0n+aq CfOg1RuKlxzupPDRbSt97P84SW6vvqovx2sr5dfY3VX6VgJ22r3IA35aJ w==; X-CSE-ConnectionGUID: oZkQDZ89Q5SepZM27ulyYA== X-CSE-MsgGUID: ECAW4WfdSZqz/49rPmF1Fw== X-IronPort-AV: E=McAfee;i="6600,9927,11095"; a="14531935" X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="14531935" 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: RnGBNQ96T4u1hzAFACMsLA== X-CSE-MsgGUID: TXyaP7z9TaKCauX2aIQdRw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="38475877" 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 D2367339; 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 3/4] regmap: cache: Switch to use kmemdup_array() Date: Thu, 6 Jun 2024 19:46:24 +0300 Message-ID: <20240606164717.3031107-4-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: quoted-printable Content-Type: text/plain; charset="utf-8" Let the kememdup_array() take care about multiplication and possible overflows. Signed-off-by: Andy Shevchenko --- drivers/base/regmap/regcache.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c index bd7462c54271..7ec1ec605335 100644 --- a/drivers/base/regmap/regcache.c +++ b/drivers/base/regmap/regcache.c @@ -170,8 +170,8 @@ int regcache_init(struct regmap *map, const struct regm= ap_config *config) * a copy of it. */ if (config->reg_defaults) { - tmp_buf =3D kmemdup(config->reg_defaults, map->num_reg_defaults * - sizeof(struct reg_default), GFP_KERNEL); + tmp_buf =3D kmemdup_array(config->reg_defaults, map->num_reg_defaults, + sizeof(*map->reg_defaults), GFP_KERNEL); if (!tmp_buf) return -ENOMEM; map->reg_defaults =3D tmp_buf; --=20 2.43.0.rc1.1336.g36b5255a03ac From nobody Thu Feb 12 21:49:29 2026 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="UNIkGz+4" 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: quoted-printable Content-Type: text/plain; charset="utf-8" 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/reg= cache-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, unsi= gned int min, lower_index =3D mas.index; lower_last =3D min -1; =20 - lower =3D kmemdup(entry, ((min - mas.index) * - sizeof(unsigned long)), - map->alloc_flags); + lower =3D kmemdup_array(entry, + min - mas.index, sizeof(*lower), + map->alloc_flags); if (!lower) { ret =3D -ENOMEM; goto out_unlocked; @@ -145,10 +145,9 @@ static int regcache_maple_drop(struct regmap *map, uns= igned int min, upper_index =3D max + 1; upper_last =3D mas.last; =20 - upper =3D kmemdup(&entry[max - mas.index + 1], - ((mas.last - max) * - sizeof(unsigned long)), - map->alloc_flags); + upper =3D kmemdup_array(&entry[max - mas.index + 1], + mas.last - max, sizeof(*upper), + map->alloc_flags); if (!upper) { ret =3D -ENOMEM; goto out_unlocked; --=20 2.43.0.rc1.1336.g36b5255a03ac