summaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/hfi1/eprom.c
diff options
context:
space:
mode:
authorSean Paul <seanpaul@chromium.org>2017-09-21 23:18:46 +0200
committerSean Paul <seanpaul@chromium.org>2017-09-21 23:18:46 +0200
commit1ebfc603d046f1dda6507d11803f9b4046cee712 (patch)
tree3be6790f2ce819929b1ccff7993c636e0944705a /drivers/infiniband/hw/hfi1/eprom.c
parentqxl: fix primary surface handling (diff)
parentMerge tag 'kbuild-fixes-v4.14' of git://git.kernel.org/pub/scm/linux/kernel/g... (diff)
downloadlinux-1ebfc603d046f1dda6507d11803f9b4046cee712.tar.xz
linux-1ebfc603d046f1dda6507d11803f9b4046cee712.zip
Merge remote-tracking branch 'origin/master' into drm-misc-fixes
Pick up 4.14-rc1 Signed-off-by: Sean Paul <seanpaul@chromium.org>
Diffstat (limited to 'drivers/infiniband/hw/hfi1/eprom.c')
-rw-r--r--drivers/infiniband/hw/hfi1/eprom.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/drivers/infiniband/hw/hfi1/eprom.c b/drivers/infiniband/hw/hfi1/eprom.c
index 26da124c88e2..d46b17107901 100644
--- a/drivers/infiniband/hw/hfi1/eprom.c
+++ b/drivers/infiniband/hw/hfi1/eprom.c
@@ -250,7 +250,6 @@ 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);
@@ -265,13 +264,13 @@ static int read_partition_platform_config(struct hfi1_devdata *dd, void **data,
/* 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;
+ if (!p) {
+ kfree(buffer);
+ return -ENOENT;
+ }
*data = buffer;
- *size = length;
+ *size = p - buffer;
return 0;
}