net: dsa: sja1105: fix error return code in sja1105_cls_flower_add()
authorWei Yongjun <weiyongjun1@huawei.com>
Mon, 15 Mar 2021 14:43:23 +0000 (14:43 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 16 Mar 2021 18:14:59 +0000 (11:14 -0700)
The return value 'rc' maybe overwrite to 0 in the flow_action_for_each
loop, the error code from the offload not support error handling will
not set. This commit fix it to return -EOPNOTSUPP.

Fixes: 6a56e19902af ("flow_offload: reject configuration of packet-per-second policing in offload drivers")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/sja1105/sja1105_flower.c

index f78b767..9737611 100644 (file)
@@ -317,14 +317,13 @@ int sja1105_cls_flower_add(struct dsa_switch *ds, int port,
        if (rc)
                return rc;
 
-       rc = -EOPNOTSUPP;
-
        flow_action_for_each(i, act, &rule->action) {
                switch (act->id) {
                case FLOW_ACTION_POLICE:
                        if (act->police.rate_pkt_ps) {
                                NL_SET_ERR_MSG_MOD(extack,
                                                   "QoS offload not support packets per second");
+                               rc = -EOPNOTSUPP;
                                goto out;
                        }