public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Dennis Dalessandro <dennis.dalessandro-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
To: dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Jan Sokolowski
	<jan.sokolowski-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	Jakub Byczkowski
	<jakub.byczkowski-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Subject: [PATCH for-next 10/10] IB/hfi1: Handle missing magic values in config file
Date: Fri, 09 Jun 2017 16:00:26 -0700	[thread overview]
Message-ID: <20170609230024.26710.48240.stgit@scvm10.sc.intel.com> (raw)
In-Reply-To: <20170609225424.26710.70167.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org>

From: Jan Sokolowski <jan.sokolowski-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

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-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Jan Sokolowski <jan.sokolowski-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 drivers/infiniband/hw/hfi1/eprom.c |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/infiniband/hw/hfi1/eprom.c b/drivers/infiniband/hw/hfi1/eprom.c
index 26da124..d46b171 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;
 }
 

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2017-06-09 23:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-09 22:59 [PATCH for-next 00/10] IB/hfi1,qib: patches for next 06/09/2017 Dennis Dalessandro
     [not found] ` <20170609225424.26710.70167.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org>
2017-06-09 22:59   ` [PATCH for-next 01/10] IB/hfi1: Fix DC 8051 host info flag array Dennis Dalessandro
2017-06-09 22:59   ` [PATCH for-next 02/10] IB/hfi1: Set proper logging levels on QSFP cable error events Dennis Dalessandro
2017-06-09 22:59   ` [PATCH for-next 03/10] IB/hfi1: Create common expected receive verbs/PSM code Dennis Dalessandro
2017-06-09 22:59   ` [PATCH for-next 04/10] IB/hfi1: Remove reading platform configuration from EFI variable Dennis Dalessandro
2017-06-09 22:59   ` [PATCH for-next 05/10] IB/hfi1: Use a template for tid reg/unreg Dennis Dalessandro
2017-06-09 22:59   ` [PATCH for-next 06/10] IB/hfi1: Add traces for TID operations Dennis Dalessandro
2017-06-09 23:00   ` [PATCH for-next 07/10] IB/qib: Replace deprecated pci functions with new API Dennis Dalessandro
     [not found]     ` <20170609230004.26710.93484.stgit-9QXIwq+3FY+1XWohqUldA0EOCMrvLtNR@public.gmane.org>
2017-06-12  9:57       ` Christoph Hellwig
     [not found]         ` <20170612095751.GA2396-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2017-06-27 21:02           ` Doug Ledford
2017-06-09 23:00   ` [PATCH for-next 08/10] IB/hfi1: Initialize TID lists to avoid crash on cleanup Dennis Dalessandro
2017-06-09 23:00   ` [PATCH for-next 09/10] IB/hfi1: Resolve kernel panics by reference counting receive contexts Dennis Dalessandro
2017-06-09 23:00   ` Dennis Dalessandro [this message]
2017-06-27 21:01   ` [PATCH for-next 00/10] IB/hfi1,qib: patches for next 06/09/2017 Doug Ledford

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170609230024.26710.48240.stgit@scvm10.sc.intel.com \
    --to=dennis.dalessandro-ral2jqcrhueavxtiumwx3w@public.gmane.org \
    --cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=jakub.byczkowski-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=jan.sokolowski-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox