From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Linus Walleij <linusw@kernel.org>,
Bartosz Golaszewski <brgl@kernel.org>,
Benson Leung <bleung@chromium.org>,
Guenter Roeck <groeck@chromium.org>,
Stephen Boyd <swboyd@chromium.org>,
patches@opensource.cirrus.com, linux-gpio@vger.kernel.org,
chrome-platform@lists.linux.dev, stable@vger.kernel.org
Subject: Re: [PATCH 6/6] gpio: cros-ec: Fix firmware node reference count underflow
Date: Thu, 3 Dec 2026 14:11:56 +0200 [thread overview]
Message-ID: <axFcjECOAf9rg5Fu@ashevche-desk.local> (raw)
In-Reply-To: <20261202-gpio-arizona-fwnode-fix-v1-6-3899179bf9d1@gmail.com>
On Wed, Dec 02, 2026 at 10:45:51PM -0800, Dmitry Torokhov wrote:
> cros_ec_gpio_probe() attaches the underlying EC protocol device's
> firmware node to the child platform device using device_set_node()
> without taking a reference. On teardown, platform_device_release() drops
> a firmware node reference and removes any attached software node,
> underflowing the protocol device's reference count and prematurely
> tearing down an attached software node.
>
> Take a reference with fwnode_handle_get() when attaching the protocol
> device's firmware node if the platform device does not already have one,
> and register cros_ec_gpio_put_fwnode() via devm_add_action_or_reset()
> before devm_gpiochip_add_data() to clear the platform device's node and
> drop the reference. Because devres runs in LIFO order, the GPIO chip and
> acpi_gpiochip_remove() on the parent device finish before the node is
> cleared, and device_del() unbinds the driver before
> device_platform_notify_remove() and platform_device_release().
>
> This preserves ACPI companion attachment for acpi_gpiochip_add(), which
> inspects the parent device while cros-ec-dev does not propagate it,
> while gpio_chip.fwnode is also assigned explicitly.
...
> + ret = devm_add_action_or_reset(dev, cros_ec_gpio_put_fwnode,
> + dev);
Don't hesitate in such a case to use longer line.
ret = devm_add_action_or_reset(dev, cros_ec_gpio_put_fwnode, dev);
is only 2 characters longer than 80. It's allowed in order to improve
readability.
> + if (ret)
> + return ret;
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2026-12-03 12:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 6:45 [PATCH 0/6] gpio: fix firmware node reference count underflows Dmitry Torokhov
2026-12-03 6:45 ` [PATCH 1/6] gpio: arizona: Fix firmware node reference count underflow Dmitry Torokhov
2026-12-03 11:28 ` Charles Keepax
2026-12-03 6:45 ` [PATCH 2/6] gpio: tps6586x: " Dmitry Torokhov
2026-12-03 6:45 ` [PATCH 3/6] gpio: tps65910: " Dmitry Torokhov
2026-12-03 6:45 ` [PATCH 4/6] gpio: twl6040: " Dmitry Torokhov
2026-12-03 6:45 ` [PATCH 5/6] gpio: wm831x: " Dmitry Torokhov
2026-12-03 11:28 ` Charles Keepax
2026-12-03 6:45 ` [PATCH 6/6] gpio: cros-ec: " Dmitry Torokhov
2026-12-03 12:11 ` Andy Shevchenko [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=axFcjECOAf9rg5Fu@ashevche-desk.local \
--to=andriy.shevchenko@linux.intel.com \
--cc=bleung@chromium.org \
--cc=brgl@kernel.org \
--cc=chrome-platform@lists.linux.dev \
--cc=dmitry.torokhov@gmail.com \
--cc=groeck@chromium.org \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=stable@vger.kernel.org \
--cc=swboyd@chromium.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