Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e4bb83fb authored by Asbjørn Sloth Tønnesen's avatar Asbjørn Sloth Tønnesen Committed by Greg Kroah-Hartman
Browse files

net: qede: sanitize 'rc' in qede_add_tc_flower_fltr()



[ Upstream commit e25714466abd9d96901b15efddf82c60a38abd86 ]

Explicitly set 'rc' (return code), before jumping to the
unlock and return path.

By not having any code depend on that 'rc' remains at
it's initial value of -EINVAL, then we can re-use 'rc' for
the return code of function calls in subsequent patches.

Only compile tested.

Signed-off-by: default avatarAsbjørn Sloth Tønnesen <ast@fiberby.net>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Stable-dep-of: fcee2065a178 ("net: qede: use return from qede_parse_flow_attr() for flower")
[ resolved conflict in v5.4, no extack for qede_parse_actions() yet ]
Signed-off-by: default avatarAsbjørn Sloth Tønnesen <ast@fiberby.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent ddec23f2
Loading
Loading
Loading
Loading
+8 −3
Original line number Original line Diff line number Diff line
@@ -1949,8 +1949,8 @@ int qede_add_tc_flower_fltr(struct qede_dev *edev, __be16 proto,
			    struct flow_cls_offload *f)
			    struct flow_cls_offload *f)
{
{
	struct qede_arfs_fltr_node *n;
	struct qede_arfs_fltr_node *n;
	int min_hlen, rc = -EINVAL;
	struct qede_arfs_tuple t;
	struct qede_arfs_tuple t;
	int min_hlen, rc;


	__qede_lock(edev);
	__qede_lock(edev);


@@ -1960,8 +1960,10 @@ int qede_add_tc_flower_fltr(struct qede_dev *edev, __be16 proto,
	}
	}


	/* parse flower attribute and prepare filter */
	/* parse flower attribute and prepare filter */
	if (qede_parse_flow_attr(edev, proto, f->rule, &t))
	if (qede_parse_flow_attr(edev, proto, f->rule, &t)) {
		rc = -EINVAL;
		goto unlock;
		goto unlock;
	}


	/* Validate profile mode and number of filters */
	/* Validate profile mode and number of filters */
	if ((edev->arfs->filter_count && edev->arfs->mode != t.mode) ||
	if ((edev->arfs->filter_count && edev->arfs->mode != t.mode) ||
@@ -1969,12 +1971,15 @@ int qede_add_tc_flower_fltr(struct qede_dev *edev, __be16 proto,
		DP_NOTICE(edev,
		DP_NOTICE(edev,
			  "Filter configuration invalidated, filter mode=0x%x, configured mode=0x%x, filter count=0x%x\n",
			  "Filter configuration invalidated, filter mode=0x%x, configured mode=0x%x, filter count=0x%x\n",
			  t.mode, edev->arfs->mode, edev->arfs->filter_count);
			  t.mode, edev->arfs->mode, edev->arfs->filter_count);
		rc = -EINVAL;
		goto unlock;
		goto unlock;
	}
	}


	/* parse tc actions and get the vf_id */
	/* parse tc actions and get the vf_id */
	if (qede_parse_actions(edev, &f->rule->action))
	if (qede_parse_actions(edev, &f->rule->action)) {
		rc = -EINVAL;
		goto unlock;
		goto unlock;
	}


	if (qede_flow_find_fltr(edev, &t)) {
	if (qede_flow_find_fltr(edev, &t)) {
		rc = -EEXIST;
		rc = -EEXIST;