Skip to content

Commit

Permalink
IB/hfi1: Handle missing magic values in config file
Browse files Browse the repository at this point in the history
Driver does not check whether proper configuration file exist in EPROM,
and treats empty partition as possible valid configuration, preventing
fallback to default firmware. Change EPROM read function to treat
missing magic number as read error.

Reviewed-by: Jakub Byczkowski <jakub.byczkowski@intel.com>
Signed-off-by: Jan Sokolowski <jan.sokolowski@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
  • Loading branch information
Jan Sokolowski authored and Doug Ledford committed Jun 27, 2017
1 parent f683c80 commit bc5214e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions drivers/infiniband/hw/hfi1/eprom.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}

Expand Down

0 comments on commit bc5214e

Please sign in to comment.