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 306A5BA44 for ; Tue, 7 Mar 2023 17:53:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8854CC433D2; Tue, 7 Mar 2023 17:53:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1678211601; bh=sk93iu3UgsiXLgJobRJEo0Akf3m8wVokf5WZjYAjJMg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZAng8tFjn4q1vm54bsibb3NVWC5umWwvea0whkzphwQXHtz0YUNJpn5wNSW+mCVrb tc6VJZMkB6+A+RCYYtsgiwQxHjsULzecJwXI4Xx2+XpXtFjs8dJHNOXpTZSXSyo9bi 07mFaHwFVW9PQZtSkIGVyC2HRPlut1LtacANzPTg= 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.2 0915/1001] hwmon: (peci/cputemp) Fix off-by-one in coretemp_label allocation Date: Tue, 7 Mar 2023 18:01:27 +0100 Message-Id: <20230307170101.759368179@linuxfoundation.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307170022.094103862@linuxfoundation.org> References: <20230307170022.094103862@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(-) --- a/drivers/hwmon/peci/cputemp.c +++ b/drivers/hwmon/peci/cputemp.c @@ -402,7 +402,7 @@ static int create_temp_label(struct peci 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;