Skip to content

Commit b389a90

Browse files
mkjkuba-moo
authored andcommitted
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 openthread/openthread#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: 7b1871a ("mctp: Warn if pointer is set for a wrong dev type") Signed-off-by: Matt Johnston <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 62e027f commit b389a90

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

net/mctp/device.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -429,12 +429,6 @@ static void mctp_unregister(struct net_device *dev)
429429
struct mctp_dev *mdev;
430430

431431
mdev = mctp_dev_get_rtnl(dev);
432-
if (mdev && !mctp_known(dev)) {
433-
// Sanity check, should match what was set in mctp_register
434-
netdev_warn(dev, "%s: BUG mctp_ptr set for unknown type %d",
435-
__func__, dev->type);
436-
return;
437-
}
438432
if (!mdev)
439433
return;
440434

@@ -451,14 +445,8 @@ static int mctp_register(struct net_device *dev)
451445
struct mctp_dev *mdev;
452446

453447
/* Already registered? */
454-
mdev = rtnl_dereference(dev->mctp_ptr);
455-
456-
if (mdev) {
457-
if (!mctp_known(dev))
458-
netdev_warn(dev, "%s: BUG mctp_ptr set for unknown type %d",
459-
__func__, dev->type);
448+
if (rtnl_dereference(dev->mctp_ptr))
460449
return 0;
461-
}
462450

463451
/* only register specific types */
464452
if (!mctp_known(dev))

0 commit comments

Comments
 (0)