Chrome platform driver development
 help / color / mirror / Atom feed
* [PATCH v2] platform/chrome: cros_ec_typec: fix missing fwnode reference decrement
@ 2024-10-13 13:20 Javier Carrasco
  2024-10-14  3:37 ` Tzung-Bi Shih
  0 siblings, 1 reply; 2+ messages in thread
From: Javier Carrasco @ 2024-10-13 13:20 UTC (permalink / raw)
  To: Prashant Malani, Benson Leung, Tzung-Bi Shih, Guenter Roeck,
	Heikki Krogerus, Enric Balletbo i Serra
  Cc: chrome-platform, linux-kernel, stable, Javier Carrasco

The device_for_each_child_node() macro requires explicit calls to
fwnode_handle_put() upon early exits (return, break, goto) to decrement
the fwnode's refcount, and avoid levaing a node reference behind.

Add the missing fwnode_handle_put() after the common label for all error
paths.

Cc: stable@vger.kernel.org
Fixes: fdc6b21e2444 ("platform/chrome: Add Type C connector class driver")
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
I usually switch to the scoped variant of the macro to fix such issues,
but given that the fix is relevant for stable kernels, I have provided
the "classical" approach by adding the missing fwnode_handle_put().

If switching to the scoped variant is desired, please let me know.
This driver and cross_typec_switch could be easily converted.
---
Changes in v2:
- fix typos in the commit description.
- Link to v1: https://lore.kernel.org/r/20241009-cross_ec_typec_fwnode_handle_put-v1-1-f17bdb48d780@gmail.com
---
 drivers/platform/chrome/cros_ec_typec.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index c7781aea0b88..f1324466efac 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -409,6 +409,7 @@ static int cros_typec_init_ports(struct cros_typec_data *typec)
 	return 0;
 
 unregister_ports:
+	fwnode_handle_put(fwnode);
 	cros_unregister_ports(typec);
 	return ret;
 }

---
base-commit: b6270c3bca987530eafc6a15f9d54ecd0033e0e3
change-id: 20241009-cross_ec_typec_fwnode_handle_put-9f13b4bd467f

Best regards,
-- 
Javier Carrasco <javier.carrasco.cruz@gmail.com>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] platform/chrome: cros_ec_typec: fix missing fwnode reference decrement
  2024-10-13 13:20 [PATCH v2] platform/chrome: cros_ec_typec: fix missing fwnode reference decrement Javier Carrasco
@ 2024-10-14  3:37 ` Tzung-Bi Shih
  0 siblings, 0 replies; 2+ messages in thread
From: Tzung-Bi Shih @ 2024-10-14  3:37 UTC (permalink / raw)
  To: Javier Carrasco
  Cc: Prashant Malani, Benson Leung, Guenter Roeck, Heikki Krogerus,
	Enric Balletbo i Serra, chrome-platform, linux-kernel, stable

On Sun, Oct 13, 2024 at 03:20:24PM +0200, Javier Carrasco wrote:
> The device_for_each_child_node() macro requires explicit calls to
> fwnode_handle_put() upon early exits (return, break, goto) to decrement
> the fwnode's refcount, and avoid levaing a node reference behind.
> 
> Add the missing fwnode_handle_put() after the common label for all error
> paths.
> 
> [...]

Applied to

    https://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux.git for-next

[1/1] platform/chrome: cros_ec_typec: fix missing fwnode reference decrement
      commit: 9c41f371457bd9a24874e3c7934d9745e87fbc58

Thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-10-14  3:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-13 13:20 [PATCH v2] platform/chrome: cros_ec_typec: fix missing fwnode reference decrement Javier Carrasco
2024-10-14  3:37 ` Tzung-Bi Shih

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox