Skip to contentSkip to conversation

mctp: Remove device type check at unregister

PATCH Applied Matt Johnston 2 participants 2 messages Dec 15, 2022 – Dec 20, 2022

Subsystems (3)
lore
Share & tools
lore

Matt Johnston

author maintainer
#0 lore raw

PATCH v2 1/1 mctp: Remove device type check at unregister

The unregister check could be incorrectly triggered if a netdev changes its type after register. That is possible for a tun device using TUNSETLINK ioctl, resulting in mctp unregister failing and the netdev unregister waiting forever.

This was encountered by https://github.com/openthread/openthread/issues/8523

Neither check at register or unregister is required. They were added in an attempt to track down mctp_ptr being set unexpectedly, which should not happen in normal operation.

Fixes 7b1871af75f3 ("mctp: Warn if pointer is set for a wrong dev type")

---

v2: Also remove the check from register

 net/mctp/device.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)
net/mctp/device.c +1 -13
index 99a3bda8852f..acb97b257428 100644
@@ -429,12 +429,6 @@ static void mctp_unregister(struct net_device *dev)
 	struct mctp_dev *mdev;
 
 	mdev = mctp_dev_get_rtnl(dev);
-	if (mdev && !mctp_known(dev)) {
-		// Sanity check, should match what was set in mctp_register
-		netdev_warn(dev, "%s: BUG mctp_ptr set for unknown type %d",
-			    __func__, dev->type);
-		return;
-	}
 	if (!mdev)
 		return;
 
@@ -451,14 +445,8 @@ static int mctp_register(struct net_device *dev)
 	struct mctp_dev *mdev;
 
 	/* Already registered? */
-	mdev = rtnl_dereference(dev->mctp_ptr);
-
-	if (mdev) {
-		if (!mctp_known(dev))
-			netdev_warn(dev, "%s: BUG mctp_ptr set for unknown type %d",
-				    __func__, dev->type);
+	if (rtnl_dereference(dev->mctp_ptr))
 		return 0;
-	}
 
 	/* only register specific types */
 	if (!mctp_known(dev))
Signature · 1 line
2.37.2
#1 lore raw
This patch was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Thu, 15 Dec 2022 13:49:33 +0800 you wrote:

The unregister check could be incorrectly triggered if a netdev changes its type after register. That is possible for a tun device using TUNSETLINK ioctl, resulting in mctp unregister failing and the netdev unregister waiting forever.

This was encountered by https://github.com/openthread/openthread/issues/8523

[...]

Here is the summary with links:
- [net,v2] mctp: Remove device type check at unregister

    https://git.kernel.org/netdev/net/c/b389a902dd5b

You are awesome, thank you!

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