From: Jonathan Cameron <jic23@kernel.org>
To: Herve Codina <herve.codina@bootlin.com>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>,
Peter Rosin <peda@axentia.se>,
Stephen Warren <swarren@nvidia.com>,
Rob Herring <robh@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Wolfram Sang <wsa@kernel.org>,
linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
Allan Nielsen <allan.nielsen@microchip.com>,
Horatiu Vultur <horatiu.vultur@microchip.com>,
Steen Hegelund <steen.hegelund@microchip.com>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: Re: [PATCH v2 2/3] i2c: muxes: i2c-demux-pinctrl: Use of_get_i2c_adapter_by_node()
Date: Fri, 20 Oct 2023 08:36:05 +0100 [thread overview]
Message-ID: <20231020083605.278df5f5@jic23-huawei> (raw)
In-Reply-To: <20231019101017.425284-3-herve.codina@bootlin.com>
On Thu, 19 Oct 2023 12:10:15 +0200
Herve Codina <herve.codina@bootlin.com> wrote:
> i2c-demux-pinctrl uses the pair of_find_i2c_adapter_by_node() /
> i2c_put_adapter(). These pair alone is not correct to properly lock the
> I2C parent adapter.
>
> Indeed, i2c_put_adapter() decrements the module refcount while
Odd spacing in here - looks like some tabs sneaked in.
> of_find_i2c_adapter_by_node() does not increment it. This leads to an
> underflow of the parent module refcount.
>
> Use the dedicated function, of_get_i2c_adapter_by_node(), to handle
> correctly the module refcount.
>
> Fixes: 50a5ba876908 ("i2c: mux: demux-pinctrl: add driver")
> Signed-off-by: Herve Codina <herve.codina@bootlin.com>
> Acked-by: Peter Rosin <peda@axentia.se>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---
> drivers/i2c/muxes/i2c-demux-pinctrl.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/muxes/i2c-demux-pinctrl.c b/drivers/i2c/muxes/i2c-demux-pinctrl.c
> index 22f2280eab7f..9f2e4aa28159 100644
> --- a/drivers/i2c/muxes/i2c-demux-pinctrl.c
> +++ b/drivers/i2c/muxes/i2c-demux-pinctrl.c
> @@ -61,7 +61,7 @@ static int i2c_demux_activate_master(struct i2c_demux_pinctrl_priv *priv, u32 ne
> if (ret)
> goto err;
>
> - adap = of_find_i2c_adapter_by_node(priv->chan[new_chan].parent_np);
> + adap = of_get_i2c_adapter_by_node(priv->chan[new_chan].parent_np);
> if (!adap) {
> ret = -ENODEV;
> goto err_with_revert;
next prev parent reply other threads:[~2023-10-20 7:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-19 10:10 [PATCH v2 0/3] Fix i2c mux module refcount issues Herve Codina
2023-10-19 10:10 ` [PATCH v2 1/3] i2c: muxes: i2c-mux-pinctrl: Use of_get_i2c_adapter_by_node() Herve Codina
2023-10-19 18:01 ` Greg Kroah-Hartman
2023-10-20 7:34 ` Jonathan Cameron
2023-10-19 10:10 ` [PATCH v2 2/3] i2c: muxes: i2c-demux-pinctrl: " Herve Codina
2023-10-19 18:01 ` Greg Kroah-Hartman
2023-10-20 7:36 ` Jonathan Cameron [this message]
2023-10-19 10:10 ` [PATCH v2 3/3] i2c: muxes: i2c-mux-gpmux: " Herve Codina
2023-10-19 18:00 ` Greg Kroah-Hartman
2023-10-20 7:37 ` Jonathan Cameron
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=20231020083605.278df5f5@jic23-huawei \
--to=jic23@kernel.org \
--cc=allan.nielsen@microchip.com \
--cc=gregkh@linuxfoundation.org \
--cc=herve.codina@bootlin.com \
--cc=horatiu.vultur@microchip.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peda@axentia.se \
--cc=robh@kernel.org \
--cc=steen.hegelund@microchip.com \
--cc=swarren@nvidia.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=wsa+renesas@sang-engineering.com \
--cc=wsa@kernel.org \
/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