Skip to content

Commit bbc126a

Browse files
Uwe Kleine-Königgregkh
authored andcommitted
usb: typec: tcpci: Don't skip cleanup in .remove() on error
Returning an error value in an i2c remove callback results in an error message being emitted by the i2c core, but otherwise it doesn't make a difference. The device goes away anyhow and the devm cleanups are called. In this case the remove callback even returns early without stopping the tcpm worker thread and various timers. A work scheduled on the work queue, or a firing timer after tcpci_remove() returned probably results in a use-after-free situation because the regmap and driver data were freed. So better make sure that tcpci_unregister_port() is called even if disabling the irq failed. Also emit a more specific error message instead of the i2c core's "remove failed (EIO), will be ignored" and return 0 to suppress the core's warning. This patch is (also) a preparation for making i2c remove callbacks return void. Fixes: 3ba7625 ("usb: typec: tcpci: mask event interrupts when remove driver") Signed-off-by: Uwe Kleine-König <[email protected]> Cc: stable <[email protected]> Acked-by: Heikki Krogerus <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 01e01f5 commit bbc126a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/usb/typec/tcpm/tcpci.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,7 @@ static int tcpci_remove(struct i2c_client *client)
877877
/* Disable chip interrupts before unregistering port */
878878
err = tcpci_write16(chip->tcpci, TCPC_ALERT_MASK, 0);
879879
if (err < 0)
880-
return err;
880+
dev_warn(&client->dev, "Failed to disable irqs (%pe)\n", ERR_PTR(err));
881881

882882
tcpci_unregister_port(chip->tcpci);
883883

0 commit comments

Comments
 (0)