Re: [PATCH v4 18/29] i2c: mux: Create missing devlink between mux and adapter physical device

From: Andy Shevchenko

Date: Thu Oct 30 2025 - 13:46:10 EST


On Thu, Oct 30, 2025 at 04:23:24PM +0100, Andi Shyti wrote:

...

> > + dl = device_link_add(muxc->dev, parent_physdev, DL_FLAG_AUTOREMOVE_CONSUMER);
>
> Not to call twice put_device, I would add it once here and then
> check for !dl.

I was almost commenting the same in one of the previous rounds, but...

> > + if (!dl) {
> > + dev_err(muxc->dev, "failed to create device link to %s\n",
> > + dev_name(parent_physdev));

...haven't you noticed this use? With your (and my old) suggestion this may
lead to NULL / stale pointer dereference.

> > + put_device(parent_physdev);
> > + ret = -EINVAL;
> > + goto err_free_priv;
> > + }
> > + put_device(parent_physdev);

--
With Best Regards,
Andy Shevchenko