Re: [RFC][2.5] list_for_each_safe not so safe (was Re: OOPS w83781d during rmmod (2.5.70-bk1[1234]))

From: Martin Schlemmer (
Date: Fri Jun 13 2003 - 01:08:48 EST

On Fri, 2003-06-13 at 04:36, Mark M. Hoffman wrote:

> > Nope, this do not fix it.
> >
> > The problem is actually at the i2c driver side. From
> > drivers/i2c/i2c-core.c in i2c_del_driver(), we have:
> <cut>
> To recap: list_for_each_safe() is not safe for deleting other than
> the current "item". But I disagree with you Martin because I think
> the usage in i2c_del_driver is ok as is; and that w83781d.c should
> change...

Right, I will not argue, as I was not sure on usage (and thus the
mail). Might be right thing (tm) to send a patch to make it more
clear that its only 'safe' for current item deletion (against
list.h) ?

> My first patch was naive; the patch below solves the problem by
> letting w83781d_detach_client remove the three clients (1 * primary
> + 2 * subclients) independently. It's a noisy patch because I had
> to change the way the subclients were kmalloc'ed - sorry. The meat
> is around line 1422. This patch works for me... comments?

I did try this way, but did it rather brutish =) It thus still did
not fix it. Your patch looks good ... I will try it tonight at home.


Martin Schlemmer

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to More majordomo info at Please read the FAQ at

This archive was generated by hypermail 2b29 : Sun Jun 15 2003 - 22:00:35 EST