Skip to content

Commit d47782d

Browse files
sumachidanandgregkh
authored andcommitted
platform/x86/amd/hsmp: Ensure sock->metric_tbl_addr is non-NULL
[ Upstream commit 2c78fb2 ] If metric table address is not allocated, accessing metrics_bin will result in a NULL pointer dereference, so add a check. Fixes: 5150542 ("platform/x86/amd/hsmp: add support for metrics tbl") Signed-off-by: Suma Hegde <suma.hegde@amd.com> Link: https://lore.kernel.org/r/20250807100637.952729-1-suma.hegde@amd.com Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 7c626f6 commit d47782d

File tree

1 file changed

+5
-0
lines changed
  • drivers/platform/x86/amd/hsmp

1 file changed

+5
-0
lines changed

drivers/platform/x86/amd/hsmp/hsmp.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,11 @@ ssize_t hsmp_metric_tbl_read(struct hsmp_socket *sock, char *buf, size_t size)
356356
if (!sock || !buf)
357357
return -EINVAL;
358358

359+
if (!sock->metric_tbl_addr) {
360+
dev_err(sock->dev, "Metrics table address not available\n");
361+
return -ENOMEM;
362+
}
363+
359364
/* Do not support lseek(), also don't allow more than the size of metric table */
360365
if (size != sizeof(struct hsmp_metric_table)) {
361366
dev_err(sock->dev, "Wrong buffer size\n");

0 commit comments

Comments
 (0)