Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp884286lqt; Fri, 7 Jun 2024 01:13:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUO8jxOzRBiEpcmyTt82iHbio2XG7HZCyAtMj9q94rvLoq+i8wd2vaTqU3aXRv4UXwfGKyF+zS7DeM6IEfvRDqWtUpUd6IzXSIeeinhTw== X-Google-Smtp-Source: AGHT+IGajy4M64rpzEO2wxZsj9OlpSinBVYdsUmLVoquCeIIXhJ5gAmZ2bJrBpGLBu+PTVDIFhl6 X-Received: by 2002:ac8:5806:0:b0:43a:e995:f1a4 with SMTP id d75a77b69052e-44041b8db75mr20911071cf.30.1717748014474; Fri, 07 Jun 2024 01:13:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717748014; cv=pass; d=google.com; s=arc-20160816; b=lS+vJq6uzBewcbtyA67n5kIq09MGfA6kwVXK1f7d46DCnGaVrCZgexnHnv7Emk7Vy3 MJ+2L6CW3YmdueKg6qc2TFFps/ASD3P0Fy9ADEJolVbZjKK6tgcgpJ/aQG0rmw4+vtYv i00mW7Yy5lTL/hAlwTW8hZs+hO30BR2/vVQwQeJTjL++O8Id1o2c+RLNxD58QhZFAkBe V6kFisXTft1qTB2wn/uWnFQ6huNwJY5uCmFudDatfOCq57j31m3wtoMO63XICE4thxUj dyHyS9ZxmYXSoj7kHUw7E5RE799k1btFXbg89SVNHmp4+qOZJvkgQcP488U+mf7QdSUe KgEQ== 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; bh=gDJROrO0tFP1H0OtUAP/qGrXl+HbXr4agmLEGMSFAgo=; fh=79CpjQYvlhGvZiy274ZfUK0yb4qzs/pzq1BXfIEDUP8=; b=fRV4bF24J2CpVzTQTBiSdxuScmlnvR335JbsPFkC4O9UCQAM228S6pmagqBQv/ynPH 9V9bLgRfQq12sExYxJRCaK2EJOihfy062p8eJMn2WKxLeTu5Ibyz1ioXOkp8jvwEIerg 8Z+CwmkyqsnS6nZc8dSkC6ebnZ5A9Nh5Zg+UpNUPWL0wi4LZrxpsJfjcC1iOmgWj2RUS 5bNwv7wGd4T4titrUAMuYpddo7bcW70+crlWnNox/8vq2LOgOLnuOW/w8SUvDf5/D31q /gRtjw4kurFfhnQvpgdn6Y8adzpCNjrfAPLfxdvl3Sp8Pvjj+pYT8dIMhs0OgkB5Jz/A xGTQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=sntech.de dmarc=pass fromdomain=sntech.de); spf=pass (google.com: domain of linux-kernel+bounces-205589-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205589-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sntech.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-44038b688dcsi34177841cf.644.2024.06.07.01.13.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 01:13:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-205589-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=sntech.de dmarc=pass fromdomain=sntech.de); spf=pass (google.com: domain of linux-kernel+bounces-205589-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205589-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sntech.de 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 2B8931C22DF9 for ; Fri, 7 Jun 2024 08:13:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C3BD015ADAF; Fri, 7 Jun 2024 08:13:27 +0000 (UTC) Received: from gloria.sntech.de (gloria.sntech.de [185.11.138.130]) (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 DD28313E043; Fri, 7 Jun 2024 08:13:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.11.138.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717748007; cv=none; b=lZ8wFnmVwFvk0bpyQcLjLlebYdjKigvJc+ZzzCi+LN1WWIuFtuiKyQUXgxOVN1Y2K1Hduv5eKXrZGxXpVFDMH529DoVCgrOXiiP8E8aV6VIKsmZaU117l45H+6T2JqtRvJzJN3eDcYC5m854WPXT2onAnf5V3eBkQmRBqkjmQC4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717748007; c=relaxed/simple; bh=VIzFG9SjjjS21ocqaupIRcoydDcwg7MVYn9fi3MKjaI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZYazl8lZaDk0S7K27RsZlqfweL/IjyML/eYAITk5k7CK1OV7HUgM6hPtwoUdROPIse2oHpqQ9z4h1FVR0iM6Bkx2NnKUDfjkwXQOhsuNQW5RB9oBcqwc5xFhU0+TGTQeFwXAYszsIhGQNIY6mTw01I0C5jmABooC3wOXAUUq4BE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sntech.de; spf=pass smtp.mailfrom=sntech.de; arc=none smtp.client-ip=185.11.138.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sntech.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sntech.de Received: from i53875b65.versanet.de ([83.135.91.101] helo=diego.localnet) by gloria.sntech.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sFUif-0000XX-SI; Fri, 07 Jun 2024 10:13:05 +0200 From: Heiko =?ISO-8859-1?Q?St=FCbner?= 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, Andy Shevchenko Cc: Michael Turquette , Stephen Boyd , Krzysztof Kozlowski , Sylwester Nawrocki , Chanwoo Choi , Alim Akhtar , Nobuhiro Iwamatsu Subject: Re: [PATCH v1 2/4] clk: rockchip: Switch to use kmemdup_array() Date: Fri, 07 Jun 2024 10:13:04 +0200 Message-ID: <8182279.JRmrKFJ9eK@diego> In-Reply-To: <20240606161028.2986587-3-andriy.shevchenko@linux.intel.com> References: <20240606161028.2986587-1-andriy.shevchenko@linux.intel.com> <20240606161028.2986587-3-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: 7Bit Content-Type: text/plain; charset="us-ascii" Hi Andy, Am Donnerstag, 6. Juni 2024, 18:09:32 CEST schrieb Andy Shevchenko: > 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); are you sure the param order is correct? According to [0], it's (src, element_size, count, gfp), while above (and below) element_size and count seems switched in the kmemdup_array calls. Heiko [0] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/mm/util.c#n149 > 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); >