All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sven Peter <sven@svenpeter.dev>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Sven Peter <sven@svenpeter.dev>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/4] usb: typec: tipd: Fix spurious fwnode_handle_put in error path
Date: Mon, 14 Nov 2022 18:44:47 +0100	[thread overview]
Message-ID: <20221114174449.34634-2-sven@svenpeter.dev> (raw)
In-Reply-To: <20221114174449.34634-1-sven@svenpeter.dev>

The err_role_put error path always calls fwnode_handle_put to release
the fwnode. This path can be reached after probe itself has already
released that fwnode though. Fix that by moving fwnode_handle_put in the
happy path to the very end.

Fixes: 18a6c866bb19 ("usb: typec: tps6598x: Add USB role switching logic")
Signed-off-by: Sven Peter <sven@svenpeter.dev>
---
 drivers/usb/typec/tipd/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
index ebc786d728e2..824e573af570 100644
--- a/drivers/usb/typec/tipd/core.c
+++ b/drivers/usb/typec/tipd/core.c
@@ -834,7 +834,6 @@ static int tps6598x_probe(struct i2c_client *client)
 		ret = PTR_ERR(tps->port);
 		goto err_role_put;
 	}
-	fwnode_handle_put(fwnode);
 
 	if (tps->status & TPS_STATUS_PLUG_PRESENT) {
 		ret = tps6598x_read16(tps, TPS_REG_POWER_STATUS, &tps->pwr_status);
@@ -858,6 +857,7 @@ static int tps6598x_probe(struct i2c_client *client)
 	}
 
 	i2c_set_clientdata(client, tps);
+	fwnode_handle_put(fwnode);
 
 	return 0;
 
-- 
2.25.1


  reply	other threads:[~2022-11-14 17:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-14 17:44 [PATCH 1/4] usb: typec: tipd: Cleanup resources if devm_tps6598_psy_register fails Sven Peter
2022-11-14 17:44 ` Sven Peter [this message]
2022-11-16 12:16   ` [PATCH 2/4] usb: typec: tipd: Fix spurious fwnode_handle_put in error path Heikki Krogerus
2022-11-14 17:44 ` [PATCH 3/4] usb: typec: tipd: Fix typec_unregister_port error paths Sven Peter
2022-11-16 12:20   ` Heikki Krogerus
2022-11-14 17:44 ` [PATCH 4/4] usb: typec: tipd: Move tps6598x_disconnect error path to its own label Sven Peter
2022-11-16 12:30   ` Heikki Krogerus
2022-11-16 12:13 ` [PATCH 1/4] usb: typec: tipd: Cleanup resources if devm_tps6598_psy_register fails Heikki Krogerus

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=20221114174449.34634-2-sven@svenpeter.dev \
    --to=sven@svenpeter.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.