mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Ritz <daniel.ritz-ml@swissonline.ch>
To: Dominik Brodowski <linux@dominikbrodowski.net>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: linux-pcmcia@lists.infradead.org,
	"linux-kernel" <linux-kernel@vger.kernel.org>
Subject: [PATCH] pcmcia/pcmcia_resource.c: fix crash when using Cardbus cards
Date: Fri, 14 Apr 2006 17:42:13 +0200	[thread overview]
Message-ID: <200604141742.13553.daniel.ritz-ml@swissonline.ch> (raw)

[PATCH] pcmcia/pcmcia_resource.c: fix crash when using Cardbus cards

using the old ioctl interface together with cardbus card gives a NULL
pointer dereference since cardbus devices don't have a struct pcmcia_device.
also s->io[0].res can be NULL as well.

fix is to move the pcmcia code after the cardbus code and to check for a null
pointer.

Signed-off-by: Daniel Ritz <daniel.ritz@gmx.ch>

diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c
index 45063b4..6572f07 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -209,7 +209,6 @@ int pccard_get_configuration_info(struct
 	if (!(s->state & SOCKET_PRESENT))
 		return CS_NO_CARD;
 
-	config->Function = p_dev->func;
 
 #ifdef CONFIG_CARDBUS
 	if (s->state & SOCKET_CARDBUS) {
@@ -223,14 +222,22 @@ #ifdef CONFIG_CARDBUS
 			config->AssignedIRQ = s->irq.AssignedIRQ;
 			if (config->AssignedIRQ)
 				config->Attributes |= CONF_ENABLE_IRQ;
-			config->BasePort1 = s->io[0].res->start;
-			config->NumPorts1 = s->io[0].res->end - config->BasePort1 + 1;
+			if (s->io[0].res) {
+				config->BasePort1 = s->io[0].res->start;
+				config->NumPorts1 = s->io[0].res->end - config->BasePort1 + 1;
+			}
 		}
 		return CS_SUCCESS;
 	}
 #endif
 
-	c = (p_dev) ? p_dev->function_config : NULL;
+	if (p_dev) {
+		c = p_dev->function_config;
+		config->Function = p_dev->func;
+	} else {
+		c = NULL;
+		config->Function = 0;
+	}
 
 	if ((c == NULL) || !(c->state & CONFIG_LOCKED)) {
 		config->Attributes = 0;

             reply	other threads:[~2006-04-14 15:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-14 15:42 Daniel Ritz [this message]
2006-04-14 16:20 ` Dominik Brodowski
2006-04-14 20:59   ` Benjamin Herrenschmidt
2006-04-14 20:59 ` Benjamin Herrenschmidt

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=200604141742.13553.daniel.ritz-ml@swissonline.ch \
    --to=daniel.ritz-ml@swissonline.ch \
    --cc=benh@kernel.crashing.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pcmcia@lists.infradead.org \
    --cc=linux@dominikbrodowski.net \
    /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

all inboxes | Powered by JetHome®