From: Jean Delvare <khali@linux-fr.org>
To: Johannes Berg <johannes@sipsolutions.net>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.de>
Cc: linuxppc-dev@ozlabs.org, alsa-devel@alsa-project.org,
Tim Shepard <shep@alum.mit.edu>
Subject: [PATCH] sound: Don't assume i2c device probing always succeeds
Date: Wed, 30 Sep 2009 15:25:42 +0200 [thread overview]
Message-ID: <20090930152542.3ef753ee@hyperion.delvare> (raw)
If i2c device probing fails, then there is no driver to dereference
after calling i2c_new_device(). Stop assuming that probing will always
succeed, to avoid NULL pointer dereferences. We have an easier access
to the driver anyway.
Reported-by: Tim Shepard <shep@alum.mit.edu>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Johannes Berg <johannes@sipsolutions.net>
---
The code is similar to the one in therm_adt746x, for which Tim reported
a real-world oops, so it should be fixed ASAP.
sound/aoa/codecs/onyx.c | 4 +++-
sound/aoa/codecs/tas.c | 4 +++-
sound/ppc/keywest.c | 4 +++-
3 files changed, 9 insertions(+), 3 deletions(-)
--- linux-2.6.32-rc1.orig/sound/aoa/codecs/onyx.c 2009-09-30 15:13:12.000000000 +0200
+++ linux-2.6.32-rc1/sound/aoa/codecs/onyx.c 2009-09-30 15:13:58.000000000 +0200
@@ -996,6 +996,8 @@ static void onyx_exit_codec(struct aoa_c
onyx->codec.soundbus_dev->detach_codec(onyx->codec.soundbus_dev, onyx);
}
+static struct i2c_driver onyx_driver;
+
static int onyx_create(struct i2c_adapter *adapter,
struct device_node *node,
int addr)
@@ -1027,7 +1029,7 @@ static int onyx_create(struct i2c_adapte
* Let i2c-core delete that device on driver removal.
* This is safe because i2c-core holds the core_lock mutex for us.
*/
- list_add_tail(&client->detected, &client->driver->clients);
+ list_add_tail(&client->detected, &onyx_driver.clients);
return 0;
}
--- linux-2.6.32-rc1.orig/sound/aoa/codecs/tas.c 2009-09-30 15:13:12.000000000 +0200
+++ linux-2.6.32-rc1/sound/aoa/codecs/tas.c 2009-09-30 15:13:58.000000000 +0200
@@ -882,6 +882,8 @@ static void tas_exit_codec(struct aoa_co
}
+static struct i2c_driver tas_driver;
+
static int tas_create(struct i2c_adapter *adapter,
struct device_node *node,
int addr)
@@ -902,7 +904,7 @@ static int tas_create(struct i2c_adapter
* Let i2c-core delete that device on driver removal.
* This is safe because i2c-core holds the core_lock mutex for us.
*/
- list_add_tail(&client->detected, &client->driver->clients);
+ list_add_tail(&client->detected, &tas_driver.clients);
return 0;
}
--- linux-2.6.32-rc1.orig/sound/ppc/keywest.c 2009-09-30 15:13:12.000000000 +0200
+++ linux-2.6.32-rc1/sound/ppc/keywest.c 2009-09-30 15:13:58.000000000 +0200
@@ -40,6 +40,8 @@ static int keywest_probe(struct i2c_clie
return 0;
}
+struct i2c_driver keywest_driver;
+
/*
* This is kind of a hack, best would be to turn powermac to fixed i2c
* bus numbers and declare the sound device as part of platform
@@ -65,7 +67,7 @@ static int keywest_attach_adapter(struct
* This is safe because i2c-core holds the core_lock mutex for us.
*/
list_add_tail(&keywest_ctx->client->detected,
- &keywest_ctx->client->driver->clients);
+ &keywest_driver.clients);
return 0;
}
--
Jean Delvare
next reply other threads:[~2009-09-30 13:25 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-30 13:25 Jean Delvare [this message]
2009-09-30 14:13 ` [PATCH] sound: Don't assume i2c device probing always succeeds Takashi Iwai
2009-09-30 14:13 ` Takashi Iwai
2009-09-30 15:00 ` Jean Delvare
2009-09-30 15:00 ` Jean Delvare
2009-09-30 15:05 ` Johannes Berg
2009-09-30 15:05 ` Johannes Berg
2009-09-30 15:57 ` Jean Delvare
2009-09-30 15:57 ` Jean Delvare
2009-09-30 15:15 ` Takashi Iwai
2009-09-30 15:15 ` Takashi Iwai
2009-09-30 16:55 ` Jean Delvare
2009-09-30 16:55 ` Jean Delvare
2009-10-01 6:52 ` Takashi Iwai
2009-10-01 6:52 ` Takashi Iwai
2009-10-04 9:35 ` Jean Delvare
2009-10-05 5:30 ` Takashi Iwai
2009-10-05 5:30 ` Takashi Iwai
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=20090930152542.3ef753ee@hyperion.delvare \
--to=khali@linux-fr.org \
--cc=alsa-devel@alsa-project.org \
--cc=johannes@sipsolutions.net \
--cc=linuxppc-dev@ozlabs.org \
--cc=perex@perex.cz \
--cc=shep@alum.mit.edu \
--cc=tiwai@suse.de \
/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.