@@ -19,6 +19,7 @@
#include <linux/dev_printk.h>
#include <linux/ioport.h>
#include <linux/kstrtox.h>
+#include <linux/nospec.h>
#include <linux/platform_device.h>
#include <linux/uuid.h>
@@ -275,6 +276,8 @@ static int init_acpi(struct device *dev)
if (sock_ind >= hsmp_pdev.num_sockets)
return -EINVAL;
+ sock_ind = array_index_nospec(sock_ind, hsmp_pdev.num_sockets);
+
ret = hsmp_parse_acpi_table(dev, sock_ind);
if (ret) {
dev_err(dev, "Failed to parse ACPI table\n");
@@ -17,6 +17,7 @@
#include <linux/device.h>
#include <linux/module.h>
#include <linux/pci.h>
+#include <linux/nospec.h>
#include <linux/platform_device.h>
#define DRIVER_NAME "amd_hsmp"
@@ -77,6 +78,8 @@ static ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj,
if (sock_ind >= hsmp_pdev.num_sockets)
return -EINVAL;
+ sock_ind = array_index_nospec(sock_ind, hsmp_pdev.num_sockets);
+
sock = &hsmp_pdev.sock[sock_ind];
if (!sock)
return -EINVAL;