[PATCH v2] i3c: master: mark OF bus child nodes OF_POPULATED to avoid legacy I2C rescan

sashiko-bot at kernel.org sashiko-bot at kernel.org
Thu Nov 26 23:12:12 PST 2026


Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] i3c: master: OF_POPULATED leaked on pre-device_add()
  registration errors
--

commit c90fe97954f10626d6c357bd037984088bf00966
Author: Billy Tsai <billy_tsai at aspeedtech.com>

i3c: master: mark OF bus child nodes OF_POPULATED to avoid legacy I2C rescan

This commit marks OF child nodes of the I3C bus with OF_POPULATED in
fwnode_populate_i3c_bus() so that i2c_register_adapter() skips them, and
clears the flag in fwnode_depopulate_i3c_bus() on error and bus cleanup.

> diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
> index 01e05bad8661e..e85307678fdcf 100644
> --- a/drivers/i3c/master.c
> +++ b/drivers/i3c/master.c
> @@ -2667,6 +2667,8 @@ static int i3c_master_bus_init(struct i3c_master_controller *master)
>  	return ret;
>  }
>  
> +static void fwnode_depopulate_i3c_bus(struct i3c_master_controller *master);
> +
>  static void i3c_master_bus_cleanup(struct i3c_master_controller *master)
>  {
>  	if (master->ops->bus_cleanup) {
> @@ -2681,6 +2683,7 @@ static void i3c_master_bus_cleanup(struct i3c_master_controller *master)
>  		}
>  	}
>  
> +	fwnode_depopulate_i3c_bus(master);
>  	i3c_master_detach_free_devs(master);
>  }

[Severity: Medium]
Does placing fwnode_depopulate_i3c_bus() in i3c_master_bus_cleanup() still
leave OF_POPULATED set when i3c_master_register_fwnode() fails after
fwnode_populate_i3c_bus() succeeds but before device_add()?

Every error path in i3c_master_register_fwnode() between
fwnode_populate_i3c_bus() and device_add(), including
i3c_master_bus_init() failure, jumps directly to err_put_dev and skips
i3c_master_bus_cleanup():

drivers/i3c/master.c:i3c_master_register_fwnode() {
	...
	ret = fwnode_populate_i3c_bus(master);
	if (ret)
		goto err_put_dev;
	...
	ret = i3c_master_bus_init(master);
	if (ret)
		goto err_put_dev;

	ret = device_add(&master->dev);
	if (ret)
		goto err_cleanup_bus;
	...
err_cleanup_bus:
	i3c_master_bus_cleanup(master);

err_put_dev:
	i3c_master_rpm_put(master);
	put_device(&master->dev);
}

If i3c_master_bus_init() fails, the OF child nodes remain marked
OF_POPULATED after registration aborts, preventing device creation on a
later re-probe or rebind.  Calling fwnode_depopulate_i3c_bus() from
i3c_masterdev_release() (or on the err_put_dev teardown path) would cover
these failures as well.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261127-i3c-master-of-populated-v2-1-c52095d00218@aspeedtech.com?part=1



More information about the linux-i3c mailing list