All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
To: lkp@lists.01.org
Subject: Re: [i2c: i2c-core] f3eab42515: WARNING: CPU: 0 PID: 1 at drivers/i2c/i2c-core.c:1930 i2c_register_driver()
Date: Mon, 07 Mar 2016 22:20:53 +0530	[thread overview]
Message-ID: <56DDB16D.4090801@gmail.com> (raw)
In-Reply-To: <56dd78c0.TTFkFGk8/5jhg0wS%fengguang.wu@intel.com>

[-- Attachment #1: Type: text/plain, Size: 1157 bytes --]

On Monday 07 March 2016 06:19 PM, kernel test robot wrote:
> Greetings,
>
> 0day kernel testing robot got the below dmesg and the first bad commit is
>
> https://github.com/0day-ci/linux Sudip-Mukherjee/i2c-i2c-core-do-not-use-bus-internal-data/20160307-195104
>
> commit f3eab4251515a492aa38e515d9a2322c535ce358
> Author:     Sudip Mukherjee <sudipm.mukherjee@gmail.com>
> AuthorDate: Mon Mar 7 17:19:17 2016 +0530
> Commit:     0day robot <fengguang.wu@intel.com>
> CommitDate: Mon Mar 7 19:51:06 2016 +0800
>
>      i2c: i2c-core: do not use bus internal data
>
>      The variable p is a data structure which is used by the driver core
>      internally and it is not expected that busses will be directly accessing
>      these driver core internal only data.
>
>      Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>

The warnings and stacktrace are expected as there was a WARN_ON() in it. 
But can you please check if the attached patch fixes the BUG: and the 
null pointer dereference. The patch will apply on top of my previous 
patch (i2c: i2c-core: do not use bus internal data).

regards
sudip




[-- Attachment #2: patch.ksh --]
[-- Type: text/plain, Size: 1253 bytes --]

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 2f31fb5..80235db 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -75,6 +75,12 @@ static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver);
 static struct static_key i2c_trace_msg = STATIC_KEY_INIT_FALSE;
 static bool is_registered;
 
+bool is_i2c_registered(void)
+{
+	return is_registered;
+}
+EXPORT_SYMBOL(is_i2c_registered);
+
 void i2c_transfer_trace_reg(void)
 {
 	static_key_slow_inc(&i2c_trace_msg);
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index 0b1108d..1939827 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -620,6 +620,9 @@ static int __init i2c_dev_init(void)
 
 	printk(KERN_INFO "i2c /dev entries driver\n");
 
+	if (!is_i2c_registered())
+		return -EAGAIN;
+
 	res = register_chrdev(I2C_MAJOR, "i2c", &i2cdev_fops);
 	if (res)
 		goto out;
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 200cf13b..24b42ff 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -36,6 +36,7 @@
 
 extern struct bus_type i2c_bus_type;
 extern struct device_type i2c_adapter_type;
+bool is_i2c_registered(void);
 
 /* --- General options ------------------------------------------------	*/
 

      reply	other threads:[~2016-03-07 16:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-07 12:49 [i2c: i2c-core] f3eab42515: WARNING: CPU: 0 PID: 1 at drivers/i2c/i2c-core.c:1930 i2c_register_driver() kernel test robot
2016-03-07 16:50 ` Sudip Mukherjee [this message]

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=56DDB16D.4090801@gmail.com \
    --to=sudipm.mukherjee@gmail.com \
    --cc=lkp@lists.01.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.