Linux-i3c Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Billy Tsai" <billy_tsai@aspeedtech.com>
Cc: linux-i3c@lists.infradead.org, Frank.Li@kernel.org,
	"Alexandre Belloni" <alexandre.belloni@bootlin.com>
Subject: Re: [PATCH v2] i3c: master: mark OF bus child nodes OF_POPULATED to avoid legacy I2C rescan
Date: Fri, 27 Nov 2026 07:12:12 +0000	[thread overview]
Message-ID: <sashiko-outbox-236789@kernel.org> (raw)
In-Reply-To: <20261127-i3c-master-of-populated-v2-1-c52095d00218@aspeedtech.com>

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@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

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

      reply	other threads:[~2026-11-27  7:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27  6:58 [PATCH v2] i3c: master: mark OF bus child nodes OF_POPULATED to avoid legacy I2C rescan Billy Tsai
2026-11-27  7:12 ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-236789@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=billy_tsai@aspeedtech.com \
    --cc=linux-i3c@lists.infradead.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox