Message ID | 20230202021825.21486-1-zev@bewilderbeest.net |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3999wrn; Wed, 1 Feb 2023 19:02:06 -0800 (PST) X-Google-Smtp-Source: AK7set9YEFeZAOXdVEs6F1+H4d2XrTXqLzkYAhTKmeyIa6HZu+oGt8/ZfuugDcbDzij50025yTZ1 X-Received: by 2002:a17:90a:193:b0:22b:ee57:724a with SMTP id 19-20020a17090a019300b0022bee57724amr4902382pjc.25.1675306926011; Wed, 01 Feb 2023 19:02:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675306925; cv=none; d=google.com; s=arc-20160816; b=Vjuey6gi0raaIWFW/zumxX4J5Gwx9kqiZrtZlzCvdNl/UNfwB/G3N8m0vmCNkEeTLF uLpmU5rcMJyoWGRz2i+XXD8Y1t93jEH/gTEFtDgrR+8GUSjlzm1Kn9hl3IMO59+MRKdj ECPqsjmML2T2E8lErF26Q3O2XlxWbYWBNCPF5UEuimPMgX+yInBK0HLsaGrNxPjbo21b jbVHzIuqaqk37NPkMxLZwt+Jesi1W8tQB0lK9P6SQhZaRxHFr7OfFndAQJToMbm+oBxS mjV1SjYYOsJdjZ7gynYYTekucbr834FTXMN0F0LhdJyvzZtpfFGQIo2LhNN6q4spF5ol bL+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=M/TiiamgoEuOPBv0/FYKxrV4c/yjfhQRaU4fbng+y9w=; b=y8mE/t45WsvtD5vYxvufva7MTpeDpZmEdX5NdlcGP/m/NVbF1HCm4WbVHu2v/bHKSn Nwzqo2Y9kCa92k4kMAYXfMZq6FBV3Wbii9z3XLXoyagr51P3Zeu9YGyK2EPmkQENheFQ gw8Q/yqS+Gg5UgfKwo+zmaX3+7zVniFxhLS5IWCTsZGbIK//ZqkEEpOrkyYn5w5syc1f byhGGT4writ90YgOg5IA5oo06j6kkviVY+l2atV2CcqjT6whilMcRwHneayyqW2oqkSa KmUdnMqxzXjgamrgtt22gmS/zr7x4YxAICb8sMP0kz+5hbOwoimupqcK8Q0TAtVGt2SM FFTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bewilderbeest.net header.s=thorn header.b=YMJRrGKK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=bewilderbeest.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e1-20020a17090ac20100b0020d5867aab6si3308305pjt.141.2023.02.01.19.01.50; Wed, 01 Feb 2023 19:02:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bewilderbeest.net header.s=thorn header.b=YMJRrGKK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=bewilderbeest.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231378AbjBBCSg (ORCPT <rfc822;il.mystafa@gmail.com> + 99 others); Wed, 1 Feb 2023 21:18:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbjBBCSf (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 1 Feb 2023 21:18:35 -0500 Received: from thorn.bewilderbeest.net (thorn.bewilderbeest.net [71.19.156.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D45746090; Wed, 1 Feb 2023 18:18:33 -0800 (PST) Received: from hatter.bewilderbeest.net (97-113-250-99.tukw.qwest.net [97.113.250.99]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: zev) by thorn.bewilderbeest.net (Postfix) with ESMTPSA id C5E923FE; Wed, 1 Feb 2023 18:18:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bewilderbeest.net; s=thorn; t=1675304313; bh=M/TiiamgoEuOPBv0/FYKxrV4c/yjfhQRaU4fbng+y9w=; h=From:To:Cc:Subject:Date:From; b=YMJRrGKKjc/poZmJMmfLqnQg1Pgp1/9mp6URbRZFO5iSMZlZyf5PFaSw1+FdV4k1e tY9+I0asH/MAcBbcPGx+LkQTD8yIX20MSAu+mSdVMzqFj9Ri+nrl3Mz+eZCf9h7s8D N/vLQApfx9yNOr08C9ABA4L8IA6zjGCP6HbNYkRc= From: Zev Weiss <zev@bewilderbeest.net> To: Iwona Winiarska <iwona.winiarska@intel.com>, Guenter Roeck <linux@roeck-us.net> Cc: Zev Weiss <zev@bewilderbeest.net>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>, Jean Delvare <jdelvare@suse.com>, Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>, openbmc@lists.ozlabs.org, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, stable@kernel.org Subject: [PATCH] hwmon: (peci/cputemp) Fix off-by-one in coretemp_label allocation Date: Wed, 1 Feb 2023 18:18:25 -0800 Message-Id: <20230202021825.21486-1-zev@bewilderbeest.net> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756686635082470808?= X-GMAIL-MSGID: =?utf-8?q?1756686635082470808?= |
Series |
hwmon: (peci/cputemp) Fix off-by-one in coretemp_label allocation
|
|
Commit Message
Zev Weiss
Feb. 2, 2023, 2:18 a.m. UTC
The find_last_bit() call produces the index of the highest-numbered
core in core_mask; because cores are numbered from zero, the number of
elements we need to allocate is one more than that.
Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Cc: stable@kernel.org # v5.18
Fixes: bf3608f338e9 ("hwmon: peci: Add cputemp driver")
---
drivers/hwmon/peci/cputemp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Wed, 2023-02-01 at 18:18 -0800, Zev Weiss wrote: > The find_last_bit() call produces the index of the highest-numbered > core in core_mask; because cores are numbered from zero, the number of > elements we need to allocate is one more than that. > > Signed-off-by: Zev Weiss <zev@bewilderbeest.net> > Cc: stable@kernel.org # v5.18 > Fixes: bf3608f338e9 ("hwmon: peci: Add cputemp driver") Thanks for catching it. Reviewed-by: Iwona Winiarska <iwona.winiarska@intel.com> > --- > drivers/hwmon/peci/cputemp.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/hwmon/peci/cputemp.c b/drivers/hwmon/peci/cputemp.c > index ec9851daf2e8..f13cc4170f58 100644 > --- a/drivers/hwmon/peci/cputemp.c > +++ b/drivers/hwmon/peci/cputemp.c > @@ -431,7 +431,7 @@ static int create_temp_label(struct peci_cputemp *priv) > unsigned long core_max = find_last_bit(priv->core_mask, > CORE_NUMS_MAX); > int i; > > - priv->coretemp_label = devm_kzalloc(priv->dev, core_max * sizeof(char > *), GFP_KERNEL); > + priv->coretemp_label = devm_kzalloc(priv->dev, (core_max + 1) * > sizeof(char *), GFP_KERNEL); > if (!priv->coretemp_label) > return -ENOMEM; >
On Wed, Feb 01, 2023 at 06:18:25PM -0800, Zev Weiss wrote: > The find_last_bit() call produces the index of the highest-numbered > core in core_mask; because cores are numbered from zero, the number of > elements we need to allocate is one more than that. > > Signed-off-by: Zev Weiss <zev@bewilderbeest.net> > Cc: stable@kernel.org # v5.18 > Fixes: bf3608f338e9 ("hwmon: peci: Add cputemp driver") > Reviewed-by: Iwona Winiarska <iwona.winiarska@intel.com> Applied. Thanks, Guenter > --- > drivers/hwmon/peci/cputemp.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/hwmon/peci/cputemp.c b/drivers/hwmon/peci/cputemp.c > index ec9851daf2e8..f13cc4170f58 100644 > --- a/drivers/hwmon/peci/cputemp.c > +++ b/drivers/hwmon/peci/cputemp.c > @@ -431,7 +431,7 @@ static int create_temp_label(struct peci_cputemp *priv) > unsigned long core_max = find_last_bit(priv->core_mask, CORE_NUMS_MAX); > int i; > > - priv->coretemp_label = devm_kzalloc(priv->dev, core_max * sizeof(char *), GFP_KERNEL); > + priv->coretemp_label = devm_kzalloc(priv->dev, (core_max + 1) * sizeof(char *), GFP_KERNEL); > if (!priv->coretemp_label) > return -ENOMEM; >
diff --git a/drivers/hwmon/peci/cputemp.c b/drivers/hwmon/peci/cputemp.c index ec9851daf2e8..f13cc4170f58 100644 --- a/drivers/hwmon/peci/cputemp.c +++ b/drivers/hwmon/peci/cputemp.c @@ -431,7 +431,7 @@ static int create_temp_label(struct peci_cputemp *priv) unsigned long core_max = find_last_bit(priv->core_mask, CORE_NUMS_MAX); int i; - priv->coretemp_label = devm_kzalloc(priv->dev, core_max * sizeof(char *), GFP_KERNEL); + priv->coretemp_label = devm_kzalloc(priv->dev, (core_max + 1) * sizeof(char *), GFP_KERNEL); if (!priv->coretemp_label) return -ENOMEM;