Commit 85c78634 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'vcap_get_rule-return-value'



Ruan Jinjie says:

====================
net: Update and fix return value check for vcap_get_rule()

As Simon Horman suggests, update vcap_get_rule() to always
return an ERR_PTR() and update the error detection conditions to
use IS_ERR(), which would be more cleaner.

So se IS_ERR() to update the return value and fix the issue
in lan966x_ptp_add_trap().

Changes in v2:
- Update vcap_get_rule() to always return an ERR_PTR().
- Update the return value fix in lan966x_ptp_add_trap().
- Update the return value check in sparx5_tc_free_rule_resources().
====================

Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 44a696de 95b358e4
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ static int lan966x_ptp_add_trap(struct lan966x_port *port,
	int err;

	vrule = vcap_get_rule(lan966x->vcap_ctrl, rule_id);
	if (vrule) {
	if (!IS_ERR(vrule)) {
		u32 value, mask;

		/* Just modify the ingress port mask and exit */
@@ -106,7 +106,7 @@ static int lan966x_ptp_del_trap(struct lan966x_port *port,
	int err;

	vrule = vcap_get_rule(lan966x->vcap_ctrl, rule_id);
	if (!vrule)
	if (IS_ERR(vrule))
		return -EEXIST;

	vcap_rule_get_key_u32(vrule, VCAP_KF_IF_IGR_PORT_MASK, &value, &mask);
+1 −1
Original line number Diff line number Diff line
@@ -1274,7 +1274,7 @@ static int sparx5_tc_free_rule_resources(struct net_device *ndev,
	int ret = 0;

	vrule = vcap_get_rule(vctrl, rule_id);
	if (!vrule || IS_ERR(vrule))
	if (IS_ERR(vrule))
		return -EINVAL;

	sparx5_tc_free_psfp_resources(sparx5, vrule);
+1 −1
Original line number Diff line number Diff line
@@ -2429,7 +2429,7 @@ struct vcap_rule *vcap_get_rule(struct vcap_control *vctrl, u32 id)

	elem = vcap_get_locked_rule(vctrl, id);
	if (!elem)
		return NULL;
		return ERR_PTR(-ENOENT);

	rule = vcap_decode_rule(elem);
	mutex_unlock(&elem->admin->lock);