Skip to contentSkip to conversation

net: pse-pd: si3474: probe error path cleanups

PATCH Applied Carlo Szelinsky 3 participants 5 messages Oct 20 – Oct 21

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover net: pse-pd: si3474: probe error path cleanups

Two small changes to the error paths in si3474 probe. They do not depend on the PSE fixes for net ("net: pse-pd: assorted lifetime and error-path fixes" v2) and apply to net-next as they are.

1 The error message after a failed devm_add_action_or_reset() reads
the ancillary I2C client, which was just unregistered.
2 Use dev_err_probe() for a failed controller registration, as

    pd692x0 and tps23881 do.

1 was found by code inspection and not reproduced. Both are build-tested only, with W=1.

Changes in v2:
- 1 was patch 9 of the net series v1 [1]. Kory asked to send it to net-next, as it is not an urgent fix. Collected his Reviewed-by.
- 2 was patch 3 of the net-next series v1 [2]. Its message no longer mentions the vpwr supply check from that series, which is not part of this version.

[1] https://lore.kernel.org/netdev/[email protected]/
[2] https://lore.kernel.org/netdev/[email protected]/

Carlo Szelinsky (2):
net: pse-pd: si3474: fix use-after-free in ancillary client error path
net: pse-pd: si3474: use dev_err_probe() for controller registration

 drivers/net/pse-pd/si3474.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

base-commit: 8cc24527d54d3ecaa09eec5a91bd107bb8b3d7d3

Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 1/2 net: pse-pd: si3474: fix use-after-free in ancillary client error path

If devm_add_action_or_reset() fails, it has already unregistered the ancillary I2C client, and the error message then reads that client's device. It can only fail with -ENOMEM, which is already reported, so drop the message.

Found by code inspection. Not reproduced.

Fixes a2317231df4b ("net: pse-pd: Add Si3474 PSE controller driver")
---
 drivers/net/pse-pd/si3474.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/pse-pd/si3474.c +1 -3
index 1845b9c51cf7..2f4f241a48af 100644
@@ -516,10 +516,8 @@ static int si3474_i2c_probe(struct i2c_client *client)
 		return PTR_ERR(priv->client[1]);
 
 	ret = devm_add_action_or_reset(dev, si3474_ancillary_i2c_remove, priv->client[1]);
-	if (ret < 0) {
-		dev_err(&priv->client[1]->dev, "Cannot register remove callback\n");
+	if (ret)
 		return ret;
-	}
 
 	ret = i2c_smbus_read_byte_data(priv->client[1], VENDOR_IC_ID_REG);
 	if (ret < 0) {
Signature · 1 line
2.43.0
#2 lore raw

PATCH v2 2/2 net: pse-pd: si3474: use dev_err_probe() for controller registration

In reply to Carlo Szelinsky

si3474 prints the error of a failed controller registration as a hex number, such as 0xfffffff4 for -ENOMEM. Use dev_err_probe(), as pd692x0 and tps23881 already do. It prints the error by name, and if the registration ever returns -EPROBE_DEFER, it does not log that as an error.

Only the log message changes.

---
 drivers/net/pse-pd/si3474.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/net/pse-pd/si3474.c +3 -4
index 2f4f241a48af..efb0af041599 100644
@@ -539,10 +539,9 @@ static int si3474_i2c_probe(struct i2c_client *client)
 	priv->pcdev.nr_lines = SI3474_MAX_CHANS;
 
 	ret = devm_pse_controller_register(dev, &priv->pcdev);
-	if (ret) {
-		dev_err(dev, "Failed to register PSE controller: 0x%x\n", ret);
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(dev, ret,
+				     "Failed to register PSE controller\n");
 
 	return 0;
 }
Signature · 1 line
2.43.0
maintainer
#3 lore raw
In reply to Carlo Szelinsky
Quoted 11 lines · Carlo Szelinsky

Two small changes to the error paths in si3474 probe. They do not depend on the PSE fixes for net ("net: pse-pd: assorted lifetime and error-path fixes" v2) and apply to net-next as they are.

1 The error message after a failed devm_add_action_or_reset() reads
the ancillary I2C client, which was just unregistered.
2 Use dev_err_probe() for a failed controller registration, as

     pd692x0 and tps23881 do.

1 was found by code inspection and not reproduced. Both are build-tested only, with W=1.

Hello,
net-next is currently close as we are in the merge window. Please resend it when it open again:
https://netdev.bots.linux.dev/net-next.html

Signature · 3 lines
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
#4 lore raw
In reply to Carlo Szelinsky
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Tue, 20 Oct 2026 19:11:31 +0200 you wrote:

Two small changes to the error paths in si3474 probe. They do not depend on the PSE fixes for net ("net: pse-pd: assorted lifetime and error-path fixes" v2) and apply to net-next as they are.

1 The error message after a failed devm_add_action_or_reset() reads
the ancillary I2C client, which was just unregistered.
2 Use dev_err_probe() for a failed controller registration, as

    pd692x0 and tps23881 do.

[...]

Here is the summary with links:
- [net-next,v2,1/2] net: pse-pd: si3474: fix use-after-free in ancillary client error path

    https://git.kernel.org/netdev/net-next/c/70c29b35fd87
  - [net-next,v2,2/2] net: pse-pd: si3474: use dev_err_probe() for controller registration
    https://git.kernel.org/netdev/net-next/c/569b57762694

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html