Skip to content

Commit 9d1817c

Browse files
marcin1jgregkh
authored andcommitted
w1: fix oops when w1_search is called from netlink connector
On Sat, Mar 02, 2013 at 10:45:10AM +0100, Sven Geggus wrote: > This is the bad commit I found doing git bisect: > 04f482f is the first bad commit > commit 04f482f > Author: Patrick McHardy <[email protected]> > Date: Mon Mar 28 08:39:36 2011 +0000 Good job. I was too lazy to bisect for bad commit;) Reading the code I found problematic kthread_should_stop call from netlink connector which causes the oops. After applying a patch, I've been testing owfs+w1 setup for nearly two days and it seems to work very reliable (no hangs, no memleaks etc). More detailed description and possible fix is given below: Function w1_search can be called from either kthread or netlink callback. While the former works fine, the latter causes oops due to kthread_should_stop invocation. This patch adds a check if w1_search is serving netlink command, skipping kthread_should_stop invocation if so. Signed-off-by: Marcin Jurkowski <[email protected]> Acked-by: Evgeniy Polyakov <[email protected]> Cc: Josh Boyer <[email protected]> Tested-by: Sven Geggus <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Cc: stable <[email protected]> # 3.0+
1 parent 34ccd87 commit 9d1817c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/w1/w1.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,8 @@ void w1_search(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb
924924
tmp64 = (triplet_ret >> 2);
925925
rn |= (tmp64 << i);
926926

927-
if (kthread_should_stop()) {
927+
/* ensure we're called from kthread and not by netlink callback */
928+
if (!dev->priv && kthread_should_stop()) {
928929
mutex_unlock(&dev->bus_mutex);
929930
dev_dbg(&dev->dev, "Abort w1_search\n");
930931
return;

0 commit comments

Comments
 (0)