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

Commit cee63723 authored by Patrick McHardy's avatar Patrick McHardy Committed by David S. Miller
Browse files

[NET_SCHED]: Propagate nla_parse return value



nla_parse() returns more detailed errno codes, propagate them back on
error.

Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ab27cfb8
Loading
Loading
Loading
Loading
+18 −11
Original line number Diff line number Diff line
@@ -473,17 +473,18 @@ struct tc_action *tcf_action_init_1(struct nlattr *nla, struct nlattr *est,
	struct nlattr *kind;
	int err;

	err = -EINVAL;

	if (name == NULL) {
		if (nla_parse_nested(tb, TCA_ACT_MAX, nla, NULL) < 0)
		err = nla_parse_nested(tb, TCA_ACT_MAX, nla, NULL);
		if (err < 0)
			goto err_out;
		err = -EINVAL;
		kind = tb[TCA_ACT_KIND];
		if (kind == NULL)
			goto err_out;
		if (nla_strlcpy(act_name, kind, IFNAMSIZ) >= IFNAMSIZ)
			goto err_out;
	} else {
		err = -EINVAL;
		if (strlcpy(act_name, name, IFNAMSIZ) >= IFNAMSIZ)
			goto err_out;
	}
@@ -548,10 +549,12 @@ struct tc_action *tcf_action_init(struct nlattr *nla, struct nlattr *est,
{
	struct nlattr *tb[TCA_ACT_MAX_PRIO+1];
	struct tc_action *head = NULL, *act, *act_prev = NULL;
	int err;
	int i;

	if (nla_parse_nested(tb, TCA_ACT_MAX_PRIO, nla, NULL) < 0)
		return ERR_PTR(-EINVAL);
	err = nla_parse_nested(tb, TCA_ACT_MAX_PRIO, nla, NULL);
	if (err < 0)
		return ERR_PTR(err);

	for (i = 1; i <= TCA_ACT_MAX_PRIO && tb[i]; i++) {
		act = tcf_action_init_1(tb[i], est, name, ovr, bind);
@@ -674,10 +677,11 @@ tcf_action_get_1(struct nlattr *nla, struct nlmsghdr *n, u32 pid)
	int index;
	int err;

	err = -EINVAL;
	if (nla_parse_nested(tb, TCA_ACT_MAX, nla, NULL) < 0)
	err = nla_parse_nested(tb, TCA_ACT_MAX, nla, NULL);
	if (err < 0)
		goto err_out;

	err = -EINVAL;
	if (tb[TCA_ACT_INDEX] == NULL ||
	    nla_len(tb[TCA_ACT_INDEX]) < sizeof(index))
		goto err_out;
@@ -759,9 +763,11 @@ static int tca_action_flush(struct nlattr *nla, struct nlmsghdr *n, u32 pid)

	b = skb_tail_pointer(skb);

	if (nla_parse_nested(tb, TCA_ACT_MAX, nla, NULL) < 0)
	err = nla_parse_nested(tb, TCA_ACT_MAX, nla, NULL);
	if (err < 0)
		goto err_out;

	err = -EINVAL;
	kind = tb[TCA_ACT_KIND];
	a->ops = tc_lookup_action(kind);
	if (a->ops == NULL)
@@ -804,12 +810,13 @@ err_out:
static int
tca_action_gd(struct nlattr *nla, struct nlmsghdr *n, u32 pid, int event)
{
	int i, ret = 0;
	int i, ret;
	struct nlattr *tb[TCA_ACT_MAX_PRIO+1];
	struct tc_action *head = NULL, *act, *act_prev = NULL;

	if (nla_parse_nested(tb, TCA_ACT_MAX_PRIO, nla, NULL) < 0)
		return -EINVAL;
	ret = nla_parse_nested(tb, TCA_ACT_MAX_PRIO, nla, NULL);
	if (ret < 0)
		return ret;

	if (event == RTM_DELACTION && n->nlmsg_flags&NLM_F_ROOT) {
		if (tb[0] != NULL && tb[1] == NULL)
+6 −1
Original line number Diff line number Diff line
@@ -61,10 +61,15 @@ static int tcf_gact_init(struct nlattr *nla, struct nlattr *est,
	struct tcf_gact *gact;
	struct tcf_common *pc;
	int ret = 0;
	int err;

	if (nla == NULL || nla_parse_nested(tb, TCA_GACT_MAX, nla, NULL) < 0)
	if (nla == NULL)
		return -EINVAL;

	err = nla_parse_nested(tb, TCA_GACT_MAX, nla, NULL);
	if (err < 0)
		return err;

	if (tb[TCA_GACT_PARMS] == NULL ||
	    nla_len(tb[TCA_GACT_PARMS]) < sizeof(*parm))
		return -EINVAL;
+5 −1
Original line number Diff line number Diff line
@@ -104,9 +104,13 @@ static int tcf_ipt_init(struct nlattr *nla, struct nlattr *est,
	u32 hook = 0;
	u32 index = 0;

	if (nla == NULL || nla_parse_nested(tb, TCA_IPT_MAX, nla, NULL) < 0)
	if (nla == NULL)
		return -EINVAL;

	err = nla_parse_nested(tb, TCA_IPT_MAX, nla, NULL);
	if (err < 0)
		return err;

	if (tb[TCA_IPT_HOOK] == NULL ||
	    nla_len(tb[TCA_IPT_HOOK]) < sizeof(u32))
		return -EINVAL;
+6 −2
Original line number Diff line number Diff line
@@ -62,12 +62,16 @@ static int tcf_mirred_init(struct nlattr *nla, struct nlattr *est,
	struct tcf_mirred *m;
	struct tcf_common *pc;
	struct net_device *dev = NULL;
	int ret = 0;
	int ret = 0, err;
	int ok_push = 0;

	if (nla == NULL || nla_parse_nested(tb, TCA_MIRRED_MAX, nla, NULL) < 0)
	if (nla == NULL)
		return -EINVAL;

	err = nla_parse_nested(tb, TCA_MIRRED_MAX, nla, NULL);
	if (err < 0)
		return err;

	if (tb[TCA_MIRRED_PARMS] == NULL ||
	    nla_len(tb[TCA_MIRRED_PARMS]) < sizeof(*parm))
		return -EINVAL;
+6 −2
Original line number Diff line number Diff line
@@ -45,13 +45,17 @@ static int tcf_nat_init(struct nlattr *nla, struct nlattr *est,
{
	struct nlattr *tb[TCA_NAT_MAX + 1];
	struct tc_nat *parm;
	int ret = 0;
	int ret = 0, err;
	struct tcf_nat *p;
	struct tcf_common *pc;

	if (nla == NULL || nla_parse_nested(tb, TCA_NAT_MAX, nla, NULL) < 0)
	if (nla == NULL)
		return -EINVAL;

	err = nla_parse_nested(tb, TCA_NAT_MAX, nla, NULL);
	if (err < 0)
		return err;

	if (tb[TCA_NAT_PARMS] == NULL ||
	    nla_len(tb[TCA_NAT_PARMS]) < sizeof(*parm))
		return -EINVAL;
Loading