From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 386A9BA49 for ; Tue, 7 Mar 2023 18:39:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8FB5EC433D2; Tue, 7 Mar 2023 18:39:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1678214392; bh=4Gel5IzMRkQbAtuXUjpbDE7WetcXyeqzZ/oUNdaKvmc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UtKvr0J47XZBJ59+qbX+czoShc2Elx7MVg72z7RJcSUKrL7ssbCt397OSmkn9PEFT bgV1KILnFs/87hWpTdxlEMqId2silwTKInMoJdPb4cokLccqv539PVh0Zqx3mLv5JA ysfEBr6l/A3KQk2WE1ZS0rVngl95G0jLfgSrzM0w= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zev Weiss , Iwona Winiarska , Guenter Roeck , stable@kernel.org Subject: [PATCH 6.1 808/885] hwmon: (peci/cputemp) Fix off-by-one in coretemp_label allocation Date: Tue, 7 Mar 2023 18:02:22 +0100 Message-Id: <20230307170036.983369186@linuxfoundation.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307170001.594919529@linuxfoundation.org> References: <20230307170001.594919529@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Zev Weiss commit f00093608fa790580da309bb9feb5108fbe7c331 upstream. 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 Cc: stable@kernel.org # v5.18 Fixes: bf3608f338e9 ("hwmon: peci: Add cputemp driver") Reviewed-by: Iwona Winiarska Link: https://lore.kernel.org/r/20230202021825.21486-1-zev@bewilderbeest.net Signed-off-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- 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 57470fda5f6c..30850a479f61 100644 --- a/drivers/hwmon/peci/cputemp.c +++ b/drivers/hwmon/peci/cputemp.c @@ -402,7 +402,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; -- 2.39.2