]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: dsa: restore error path of dsa_tree_change_tag_proto
authorVladimir Oltean <vladimir.oltean@nxp.com>
Mon, 28 Feb 2022 14:17:15 +0000 (16:17 +0200)
committerJakub Kicinski <kuba@kernel.org>
Wed, 2 Mar 2022 02:26:21 +0000 (18:26 -0800)
When the DSA_NOTIFIER_TAG_PROTO returns an error, the user space process
which initiated the protocol change exits the kernel processing while
still holding the rtnl_mutex. So any other process attempting to lock
the rtnl_mutex would deadlock after such event.

The error handling of DSA_NOTIFIER_TAG_PROTO was inadvertently changed
by the blamed commit, introducing this regression. We must still call
rtnl_unlock(), and we must still call DSA_NOTIFIER_TAG_PROTO for the old
protocol. The latter is due to the limiting design of notifier chains
for cross-chip operations, which don't have a built-in error recovery
mechanism - we should look into using notifier_call_chain_robust for that.

Fixes: dc452a471dba ("net: dsa: introduce tagger-owned storage for private and shared data")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Link: https://lore.kernel.org/r/20220228141715.146485-1-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/dsa/dsa2.c

index dcad3100b164637fd581d70ba20e4b31ae6e8a6b..209496996cdfafe6f8509ea1fbabc1ecb51db642 100644 (file)
@@ -1261,7 +1261,7 @@ int dsa_tree_change_tag_proto(struct dsa_switch_tree *dst,
        info.tag_ops = tag_ops;
        err = dsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO, &info);
        if (err)
-               return err;
+               goto out_unlock;
 
        err = dsa_tree_bind_tag_proto(dst, tag_ops);
        if (err)