[PATCH net] can: netlink: fix static FD-NON-ISO mode validation
From: Zhu Ling
Date: Fri Sep 04 2026 - 12:36:49 EST
can_ctrlmode_changelink() calculates ctrlstatic_missing before removing
CAN_CTRLMODE_FD_NON_ISO from the static control modes when CAN FD is
disabled. Consequently, the exception has no effect and disabling CAN FD
on a controller with a static FD-NON-ISO mode fails with -EOPNOTSUPP.
Calculate ctrlstatic_missing after adjusting ctrlstatic, restoring the
behavior from before the offending commit.
Fixes: 6742ca18cb41 ("can: netlink: add userland error messages")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Zhu Ling <zhuling0805@xxxxxx>
---
drivers/net/can/dev/netlink.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/can/dev/netlink.c b/drivers/net/can/dev/netlink.c
index 766d455950f5..26983f1b4077 100644
--- a/drivers/net/can/dev/netlink.c
+++ b/drivers/net/can/dev/netlink.c
@@ -321,7 +321,6 @@ static int can_ctrlmode_changelink(struct net_device *dev,
maskedflags = cm->flags & cm->mask;
deactivated = ~cm->flags & cm->mask;
notsupp = maskedflags & ~(priv->ctrlmode_supported | ctrlstatic);
- ctrlstatic_missing = (maskedflags & ctrlstatic) ^ ctrlstatic;
if (notsupp) {
NL_SET_ERR_MSG_FMT(extack,
@@ -334,6 +333,7 @@ static int can_ctrlmode_changelink(struct net_device *dev,
if (!(maskedflags & CAN_CTRLMODE_FD))
ctrlstatic &= ~CAN_CTRLMODE_FD_NON_ISO;
+ ctrlstatic_missing = (maskedflags & ctrlstatic) ^ ctrlstatic;
if (ctrlstatic_missing) {
NL_SET_ERR_MSG_FMT(extack,
"missing required %s static control mode",
base-commit: 641d03105cc0d2437e32fdeec164f91a4ccef6c4
--
2.43.0