summaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/hfi1/eprom.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2017-10-14 10:11:45 +0200
committerIngo Molnar <mingo@kernel.org>2017-10-14 10:11:45 +0200
commit6edcf57233108df2e50ab5d3fa695ea958b4c779 (patch)
tree7f233132de3cf1d438ac5ca51cfa6e9c48f8b86f /drivers/infiniband/hw/hfi1/eprom.c
parentx86/unwinder: Make CONFIG_UNWINDER_ORC=y the default in the 64-bit defconfig (diff)
parentobjtool: Upgrade libelf-devel warning to error for CONFIG_ORC_UNWINDER (diff)
downloadlinux-6edcf57233108df2e50ab5d3fa695ea958b4c779.tar.xz
linux-6edcf57233108df2e50ab5d3fa695ea958b4c779.zip
Merge branch 'core/urgent' into x86/asm, to pick up dependency
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'drivers/infiniband/hw/hfi1/eprom.c')
-rw-r--r--drivers/infiniband/hw/hfi1/eprom.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/drivers/infiniband/hw/hfi1/eprom.c b/drivers/infiniband/hw/hfi1/eprom.c
index d46b17107901..1613af1c58d9 100644
--- a/drivers/infiniband/hw/hfi1/eprom.c
+++ b/drivers/infiniband/hw/hfi1/eprom.c
@@ -204,7 +204,10 @@ done_asic:
return ret;
}
-/* magic character sequence that trails an image */
+/* magic character sequence that begins an image */
+#define IMAGE_START_MAGIC "APO="
+
+/* magic character sequence that might trail an image */
#define IMAGE_TRAIL_MAGIC "egamiAPO"
/* EPROM file types */
@@ -250,6 +253,7 @@ static int read_partition_platform_config(struct hfi1_devdata *dd, void **data,
{
void *buffer;
void *p;
+ u32 length;
int ret;
buffer = kmalloc(P1_SIZE, GFP_KERNEL);
@@ -262,15 +266,21 @@ static int read_partition_platform_config(struct hfi1_devdata *dd, void **data,
return ret;
}
- /* scan for image magic that may trail the actual data */
- p = strnstr(buffer, IMAGE_TRAIL_MAGIC, P1_SIZE);
- if (!p) {
+ /* config partition is valid only if it starts with IMAGE_START_MAGIC */
+ if (memcmp(buffer, IMAGE_START_MAGIC, strlen(IMAGE_START_MAGIC))) {
kfree(buffer);
return -ENOENT;
}
+ /* scan for image magic that may trail the actual data */
+ p = strnstr(buffer, IMAGE_TRAIL_MAGIC, P1_SIZE);
+ if (p)
+ length = p - buffer;
+ else
+ length = P1_SIZE;
+
*data = buffer;
- *size = p - buffer;
+ *size = length;
return 0;
}