Re: [PATCH v2] iio: light: veml6070: Fix resource leak in probe error path

From: Jonathan Cameron

Date: Sun Apr 12 2026 - 11:59:01 EST


On Fri, 27 Mar 2026 20:27:54 +0800
Felix Gu <ustc.gu@xxxxxxxxx> wrote:

> The driver calls i2c_new_dummy_device() to create a dummy device,
> then calls i2c_smbus_write_byte(). If i2c_smbus_write_byte() fails and
> returns, the cleanup via devm_add_action_or_reset() was never registered,
> so the dummy device leaks.
>
> Switch to devm_i2c_new_dummy_device() which registers cleanup atomically
> with device creation, eliminating the error-path window.
>
> Fixes: 7501bff87c3e ("iio: light: veml6070: add action for i2c_unregister_device")
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>
> Signed-off-by: Felix Gu <ustc.gu@xxxxxxxxx>
Applied to the fixes-togreg branch of iio.git and marked for stable.

Thanks,

Jonathan