public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org, sensors@stimpy.netroedge.com
Subject: Re: [PATCH] I2C update for 2.6.10-rc1
Date: Mon, 8 Nov 2004 21:24:17 -0800	[thread overview]
Message-ID: <10999778572385@kroah.com> (raw)
In-Reply-To: <10999778574012@kroah.com>

ChangeSet 1.2014.1.21, 2004/11/08 16:45:21-08:00, khali@linux-fr.org

[PATCH] I2C: Check for unregistered adapter in i2c_del_adapter

The patch adds a check at the beginning of i2c_del_adapter in case
someone attempts to remove an adapter that was never added in the first
place. This sounds like a good safety, as doing so will lead to an oops
at the moment. Also, I have a need for it in the latest version of my
i2c-amd756-s4882 patch. I need to remove the original adapter and
install the virtual ones instead, but I have no way to know if the
original adapter was succesfully added beforehand or not.


Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>


 drivers/i2c/i2c-core.c |   13 +++++++++++++
 1 files changed, 13 insertions(+)


diff -Nru a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
--- a/drivers/i2c/i2c-core.c	2004-11-08 18:54:39 -08:00
+++ b/drivers/i2c/i2c-core.c	2004-11-08 18:54:39 -08:00
@@ -177,11 +177,24 @@
 int i2c_del_adapter(struct i2c_adapter *adap)
 {
 	struct list_head  *item, *_n;
+	struct i2c_adapter *adap_from_list;
 	struct i2c_driver *driver;
 	struct i2c_client *client;
 	int res = 0;
 
 	down(&core_lists);
+
+	/* First make sure that this adapter was ever added */
+	list_for_each_entry(adap_from_list, &adapters, list) {
+		if (adap_from_list == adap)
+			break;
+	}
+	if (adap_from_list != adap) {
+		pr_debug("I2C: Attempting to delete an unregistered "
+			 "adapter\n");
+		res = -EINVAL;
+		goto out_unlock;
+	}
 
 	list_for_each(item,&drivers) {
 		driver = list_entry(item, struct i2c_driver, list);


  reply	other threads:[~2004-11-09  5:27 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-09  5:22 [BK PATCH] I2C update for 2.6.10-rc1 Greg KH
2004-11-09  5:24 ` [PATCH] " Greg KH
2004-11-09  5:24   ` Greg KH
2004-11-09  5:24     ` Greg KH
2004-11-09  5:24       ` Greg KH
2004-11-09  5:24         ` Greg KH
2004-11-09  5:24           ` Greg KH
2004-11-09  5:24             ` Greg KH
2004-11-09  5:24               ` Greg KH
2004-11-09  5:24                 ` Greg KH
2004-11-09  5:24                   ` Greg KH
2004-11-09  5:24                     ` Greg KH
2004-11-09  5:24                       ` Greg KH
2004-11-09  5:24                         ` Greg KH
2004-11-09  5:24                           ` Greg KH
2004-11-09  5:24                             ` Greg KH
2004-11-09  5:24                               ` Greg KH
2004-11-09  5:24                                 ` Greg KH
2004-11-09  5:24                                   ` Greg KH
2004-11-09  5:24                                     ` Greg KH
2004-11-09  5:24                                       ` Greg KH
2004-11-09  5:24                                         ` Greg KH [this message]
2004-11-09  5:24                                           ` Greg KH
2004-11-09  5:24                                             ` Greg KH
2004-11-09  5:24                                               ` Greg KH
2004-11-09 10:17                 ` Jean Delvare
2004-11-09 11:12                   ` Arjan van de Ven
2004-11-09 14:10                     ` Jean Delvare
2004-11-09  9:29 ` [BK PATCH] " Jean Delvare
2004-11-09 15:21   ` Greg KH

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=10999778572385@kroah.com \
    --to=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sensors@stimpy.netroedge.com \
    /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