]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
iio: light: veml6070: Fix resource leak in probe error path
authorFelix Gu <ustc.gu@gmail.com>
Fri, 27 Mar 2026 12:27:54 +0000 (20:27 +0800)
committerJonathan Cameron <jic23@kernel.org>
Tue, 28 Apr 2026 15:36:09 +0000 (16:36 +0100)
commitb66f922f6a4fa92840f662fbcfeb4f8a0f774bcc
treef0e49a6cf7a2389790154fd78f9a432f1c5937f7
parent673478bc29cf72010faaf293c1c8c667393335a0
iio: light: veml6070: Fix resource leak in probe error path

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@intel.com>
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/light/veml6070.c