This patch adds a check if CAN_CTRLMODE_FD_COMMON_BRP is obeyed and rejects the CAN-FD bitrate settings if the selected bitrate prescalers for the nominal and data bitrate don't match. Signed-off-by: Stefan Mätje <stefan.maetje@xxxxxx> --- drivers/net/can/dev/netlink.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/can/dev/netlink.c b/drivers/net/can/dev/netlink.c index 79328d70759a..9a043c2b8bba 100644 --- a/drivers/net/can/dev/netlink.c +++ b/drivers/net/can/dev/netlink.c @@ -360,6 +360,13 @@ static int can_changelink(struct net_device *dev, struct nlattr *tb[], if (err) return err; } + if ((priv->ctrlmode & CAN_CTRLMODE_FD_COMMON_BRP) && + (priv->bittiming.brp != priv->data_bittiming.brp)) { + NL_SET_ERR_MSG_FMT(extack, + "CTRLMODE_FD_COMMON_BRP not fulfilled (NBRP: %u, DBRP: %u)", + priv->bittiming.brp, priv->data_bittiming.brp); + return -EINVAL; + } } if (data[IFLA_CAN_TERMINATION]) { -- 2.34.1