Linux USB
 help / color / mirror / Atom feed
* [PATCH] usb: typec: tipd: cancel the poll work on probe error
@ 2026-11-30 12:54 Cong Nguyen
  2026-11-30 13:08 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Cong Nguyen @ 2026-11-30 12:54 UTC (permalink / raw)
  To: Heikki Krogerus, Greg Kroah-Hartman
  Cc: Roger Quadros, linux-usb, linux-kernel

In polling mode tps6598x_probe() queues wq_poll and then tests ret. If
the connect() callback failed earlier, ret still holds that error, so
probe jumps to err_disconnect with the poll work queued. Nothing cancels
it before the devm-allocated tps is freed.

Cancel the poll work at err_disconnect, as tps6598x_remove() does.

Fixes: 0d6a119cecd7 ("usb: typec: tps6598x: Add support for polling interrupts status")
Signed-off-by: Cong Nguyen <congnt264@gmail.com>
---
 drivers/usb/typec/tipd/core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
index 02539378ffed..991d42e35777 100644
--- a/drivers/usb/typec/tipd/core.c
+++ b/drivers/usb/typec/tipd/core.c
@@ -1928,6 +1928,8 @@ static int tps6598x_probe(struct i2c_client *client)
 	return 0;
 
 err_disconnect:
+	if (!client->irq)
+		cancel_delayed_work_sync(&tps->wq_poll);
 	tps6598x_disconnect(tps, 0);
 err_unregister_port:
 	tps->data->unregister_port(tps);
-- 
2.25.1


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

* Re: [PATCH] usb: typec: tipd: cancel the poll work on probe error
  2026-11-30 12:54 [PATCH] usb: typec: tipd: cancel the poll work on probe error Cong Nguyen
@ 2026-11-30 13:08 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-30 13:08 UTC (permalink / raw)
  To: Cong Nguyen; +Cc: linux-usb

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] usb: typec: tipd: tps6598x_probe() queues wq_poll after
  connect() error
--

commit d10e175d4dc048ad0066d5eb5967c060b86270e0
Author: Cong Nguyen <congnt264@gmail.com>

usb: typec: tipd: cancel the poll work on probe error

This commit cancels tps->wq_poll on the err_disconnect error path in
tps6598x_probe() when running in polling mode.

> diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
> index 02539378ffeda..991d42e35777a 100644
> --- a/drivers/usb/typec/tipd/core.c
> +++ b/drivers/usb/typec/tipd/core.c
> @@ -1928,6 +1928,8 @@ static int tps6598x_probe(struct i2c_client *client)
>  	return 0;
>  
>  err_disconnect:
> +	if (!client->irq)
> +		cancel_delayed_work_sync(&tps->wq_poll);
>  	tps6598x_disconnect(tps, 0);
>  err_unregister_port:
>  	tps->data->unregister_port(tps);

[Severity: Medium]
Why queue tps->wq_poll when ret is already non-zero, only to immediately
jump to err_disconnect and cancel it?

drivers/usb/typec/tipd/core.c:tps6598x_probe() {
    ...
		ret = tps->data->connect(tps, status);
		if (ret)
			dev_err(&client->dev, "failed to register partner\n");
	}

	if (client->irq) {
		ret = devm_request_threaded_irq(&client->dev, client->irq, NULL,
						tps->data->irq_handler,
						IRQF_SHARED | IRQF_ONESHOT,
						dev_name(&client->dev), tps);
	} else {
		dev_dbg(tps->dev, "no IRQ specified, using polling mode\n");
		INIT_DELAYED_WORK(&tps->wq_poll, tps6598x_poll_work);
		queue_delayed_work(system_power_efficient_wq, &tps->wq_poll,
				   msecs_to_jiffies(POLL_INTERVAL));
	}

	if (ret)
		goto err_disconnect;
    ...
}

In IRQ mode, devm_request_threaded_irq() overwrites ret from
tps->data->connect(), so an initial partner registration error is logged
and probe succeeds.  In polling mode, nothing after queue_delayed_work()
sets ret or jumps to err_disconnect, so a connect() failure queues
tps->wq_poll, immediately cancels it, and fails the controller probe.
Checking ret inside the if (client->irq) block (or before it if connect()
failures are meant to be fatal in both modes) would avoid queuing and
immediately canceling tps->wq_poll.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261130125448.2300198-1-congnt264@gmail.com?part=1

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

end of thread, other threads:[~2026-11-30 13:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 12:54 [PATCH] usb: typec: tipd: cancel the poll work on probe error Cong Nguyen
2026-11-30 13:08 ` sashiko-bot

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