[PATCH 3/3] debugging w1_therm race condition

From: David Fries
Date: Sun Mar 08 2015 - 15:01:28 EST


---
drivers/w1/slaves/w1_therm.c | 4 ++++
drivers/w1/w1.c | 4 ++++
2 files changed, 8 insertions(+)

diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c
index cb46e85..cb0fe1b 100644
--- a/drivers/w1/slaves/w1_therm.c
+++ b/drivers/w1/slaves/w1_therm.c
@@ -80,11 +80,13 @@ static int w1_therm_add_slave(struct w1_slave *sl)

static void w1_therm_remove_slave(struct w1_slave *sl)
{
+ printk(KERN_NOTICE "%s about to lock faily_data->lock\n", __func__);
/* Getting the lock means w1_slave_show isn't sleeping and the
* family_data can be freed.
*/
mutex_lock(THERM_LOCK(sl));
mutex_unlock(THERM_LOCK(sl));
+ printk(KERN_NOTICE "%s unlocked faily_data->lock\n", __func__);
kfree(sl->family_data);
sl->family_data = NULL;
}
@@ -248,7 +250,9 @@ static ssize_t w1_slave_show(struct device *device,
mutex_unlock(&dev->bus_mutex);

//sleep_rem = msleep_interruptible(tm);
+ printk(KERN_NOTICE "start sleep %p refcnt %u\n", sl, atomic_read(&sl->refcnt));
sleep_rem = msleep_interruptible(10*1000);
+ printk(KERN_NOTICE "end sleep %p refcnt %u\n", sl, atomic_read(&sl->refcnt));
if (sleep_rem != 0) {
ret = -EINTR;
goto post_unlock;
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 181f41c..9bb3116 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -650,8 +650,10 @@ static int w1_family_notify(unsigned long action, struct w1_slave *sl)
case BUS_NOTIFY_DEL_DEVICE:
if (fops->remove_slave)
sl->family->fops->remove_slave(sl);
+ printk(KERN_NOTICE "calling sysfs_remove_groups\n");
if (fops->groups)
sysfs_remove_groups(&sl->dev.kobj, fops->groups);
+ printk(KERN_NOTICE "returned sysfs_remove_groups\n");
break;
}
return 0;
@@ -769,6 +771,7 @@ int w1_unref_slave(struct w1_slave *sl)
int refcnt;
mutex_lock(&dev->list_mutex);
refcnt = atomic_sub_return(1, &sl->refcnt);
+ printk(KERN_NOTICE "%s slave %p refcnt now %u\n", __func__, sl, refcnt);
if (refcnt == 0) {
struct w1_netlink_msg msg;

@@ -788,6 +791,7 @@ int w1_unref_slave(struct w1_slave *sl)
memset(sl, 0, sizeof(*sl));
#endif
kfree(sl);
+ printk(KERN_NOTICE "%s w1_slave %p\n", __func__, sl);
}
atomic_dec(&dev->refcnt);
mutex_unlock(&dev->list_mutex);
--
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/