Re: [PATCH] i2c: core: fix potential use-after-free on adapter removal

From: Wolfram Sang
Date: Thu Jun 16 2022 - 15:33:08 EST


Hi Michał,

> I looked briefly at the kobject machinery and it seems to ignore module
> dependencies. So while both approaches might work, I'd usually reverse

Thanks for checking!

> the order the init code is using: in this case module_get+device_get,
> so on release: device_put+module_put. I don't know what keeps the kernel

I agree this is good style. I'll add a comment why we reverse the order.
This will be also good to avoid regressions.

> from unloading the module after module_put() and before the function
> returns, but I assume that would blow up for both patches.

Yes. There are other users in the kernel doing it like this (RTC and
regmap IIRC), so I think problems would have become visible by then.

Thank you for your help!

Wolfram

Attachment: signature.asc
Description: PGP signature