Skip to contentSkip to conversation

subclient leak in asb100 driver

DISCUSSION Jean Delvare 2 participants 5 messages May 19, 2005

lore
Share & tools
lore
#0 lore raw

Hi Mark,

I think that there is a i2c client and memory leak in your asb100 driver (2.4/CVS). In asb100_detach_client, you neither call i2c_detach_client on subclients, nor do you kfree their memory.

Could you please take a look?

I think that the same problem exists in the 2.6 version of the driver, as well as in the w83781d driver there. The 2.4/CVS version of the w83781d driver, on the other hand, seems OK.

Thanks.

Signature · 2 lines
Jean Delvare
http://www.ensicaen.ismra.fr/~delvare/
#1 lore raw
Quoted 3 lines · Jean Delvare

I think that there is a i2c client and memory leak in your asb100 driver (2.4/CVS). In asb100_detach_client, you neither call i2c_detach_client on subclients, nor do you kfree their memory.

Nope, the I2C core calls asb100_detach_client() three times... once for the primary client and twice more for the subclients.

Quoted 3 lines

I think that the same problem exists in the 2.6 version of the driver, as well as in the w83781d driver there. The 2.4/CVS version of the w83781d driver, on the other hand, seems OK.

The changes in 2.6 are also on purpose. They're necessary because the I2C client list was implemented differently than in 2.4, which caused it to try to release the subclients twice.

I.e. technically, it's the CVS w83781d driver that's wrong... although it happens to be benign vs. 2.4 kernel.

Regards,

Signature · 2 lines
Mark M. Hoffman
[email protected]
#2 lore raw
In reply to Jean Delvare
Quoted 2 lines

Nope, the I2C core calls asb100_detach_client() three times... once for the primary client and twice more for the subclients.

Ohhhh OK. Now I get it. It's a bit confusing at first. I'd have expected two different detach functions (i.e. two different driver structures). But I agree it works.

Quoted 3 lines

The changes in 2.6 are also on purpose. They're necessary because the I2C client list was implemented differently than in 2.4, which caused it to try to release the subclients twice.

I didn't see much change, except the sysctl_id being gone.

Quoted 2 lines

I.e. technically, it's the CVS w83781d driver that's wrong... although it happens to be benign vs. 2.4 kernel.

Yes, I see that now. I'm surprised that it doesn't cause more trouble than it does. Care to correct the 2.4/CVS driver so that it does what your asb100 driver does (i.e. the right thing)?

Thanks.

Signature · 2 lines
Jean Delvare
http://www.ensicaen.ismra.fr/~delvare/
#3 lore raw
In reply to Jean Delvare

Hi Mark,

Quoted 6 lines
Quoted 2 lines

I.e. technically, it's the CVS w83781d driver that's wrong... although it happens to be benign vs. 2.4 kernel.

Yes, I see that now. I'm surprised that it doesn't cause more trouble than it does. Care to correct the 2.4/CVS driver so that it does what your asb100 driver does (i.e. the right thing)?

I took a longer look at the w83781d driver and finally, it doesn't seem to be broken. It simply relies on the fact that i2c-core will detach the clients on the same order they were attached. Since the w83781d driver attached the main client before attaching the subclients, the main client is detached first. In the callback function, the driver detaches the subclients "manually" (as opposed to letting i2c-core take care). When returning from the callback function, the subclients are already gone, so i2c-core doesn't do anything for them (verified).

So I don't think there's anything that needs fixing here. Let me know if I missed something.

Signature · 2 lines
Jean Delvare
http://khali.linux-fr.org/
#4 lore raw
In reply to Jean Delvare
Quoted 9 lines · Jean Delvare

Hi Mark,

Quoted 6 lines
Quoted 2 lines

I.e. technically, it's the CVS w83781d driver that's wrong... although it happens to be benign vs. 2.4 kernel.

Yes, I see that now. I'm surprised that it doesn't cause more trouble than it does. Care to correct the 2.4/CVS driver so that it does what your asb100 driver does (i.e. the right thing)?

Quoted 8 lines

I took a longer look at the w83781d driver and finally, it doesn't seem to be broken. It simply relies on the fact that i2c-core will detach the clients on the same order they were attached. Since the w83781d driver attached the main client before attaching the subclients, the main client is detached first. In the callback function, the driver detaches the subclients "manually" (as opposed to letting i2c-core take care). When returning from the callback function, the subclients are already gone, so i2c-core doesn't do anything for them (verified).

Exactly. That's what I meant by "happens to be benign".

Quoted 2 lines

So I don't think there's anything that needs fixing here. Let me know if I missed something.

That's fine with me.

Regards,

Signature · 2 lines
Mark M. Hoffman
[email protected]