All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Cox <alan@linux.intel.com>
To: linux-kernel@vger.kernel.org, linux-pcmica@lists.infradead.org
Subject: [PATCH 2/5] pcmcia cis: on an out of range CIS read return 0xff, don't just warn
Date: Thu, 04 Dec 2014 21:29:22 +0000	[thread overview]
Message-ID: <20141204212903.1351.22063.stgit@localhost.localdomain> (raw)
In-Reply-To: <20141204212746.1351.89165.stgit@localhost.localdomain>

The current code displays warnings but then proceeds to try and reference
the data through the PCMCIA window. Instead return 0xff. This prevents bogus
CIS data sending us off into hyperspace.

Signed-off-by: Alan Cox <alan@linux.intel.com>
---
 drivers/pcmcia/cistpl.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c
index 884a984..4ff725c 100644
--- a/drivers/pcmcia/cistpl.c
+++ b/drivers/pcmcia/cistpl.c
@@ -168,9 +168,12 @@ int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr, u_int addr,
 	} else {
 		u_int inc = 1, card_offset, flags;
 
-		if (addr > CISTPL_MAX_CIS_SIZE)
+		if (addr > CISTPL_MAX_CIS_SIZE) {
 			dev_dbg(&s->dev,
 				"attempt to read CIS mem at addr %#x", addr);
+			memset(ptr, 0xff, len);
+			return -1;
+		}
 
 		flags = MAP_ACTIVE | ((cis_width) ? MAP_16BIT : 0);
 		if (attr) {


  parent reply	other threads:[~2014-12-04 21:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-04 21:28 [PATCH 0/5] pcmcia: 64bit fixes, anonymous cards, other bugs Alan Cox
2014-12-04 21:28 ` [PATCH 1/5] pcmcia: correct types Alan Cox
2014-12-04 21:29 ` Alan Cox [this message]
2014-12-04 21:30 ` [PATCH 3/5] pcmcia: Fix requery Alan Cox
2014-12-04 21:30 ` [PATCH 4/5] pcmcia: handle anonymous cards by generating a fake CIS Alan Cox
2015-06-14 19:52   ` Dominik Brodowski
2015-06-15 12:10     ` Alan Cox
2015-06-16  6:19       ` Dominik Brodowski
2014-12-04 21:31 ` [PATCH 5/5] pcmcia: add a new resource manager for non ISA systems Alan Cox
2015-05-30 14:40   ` Dominik Brodowski
2015-06-01 13:59     ` Alan Cox

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=20141204212903.1351.22063.stgit@localhost.localdomain \
    --to=alan@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pcmica@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.