From: Patrick McHardy <kaber@trash.net>
To: jamal <hadi@cyberus.ca>
Cc: Maillist netdev <netdev@oss.sgi.com>
Subject: [PATCH PKT_SCHED 20/22]: act_api.c: push memory allocation to tcf_action_get_1
Date: Mon, 10 Jan 2005 20:38:16 +0100 [thread overview]
Message-ID: <41E2D9A8.9080003@trash.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 1 bytes --]
[-- Attachment #2: 20.diff --]
[-- Type: text/x-patch, Size: 2514 bytes --]
# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
# 2005/01/10 05:47:32+01:00 kaber@coreworks.de
# [PKT_SCHED]: act_api.c: push memory allocation to tcf_action_get_1
#
# Signed-off-by: Patrick McHardy <kaber@trash.net>
#
# net/sched/act_api.c
# 2005/01/10 05:47:25+01:00 kaber@coreworks.de +30 -18
# [PKT_SCHED]: act_api.c: push memory allocation to tcf_action_get_1
#
# Signed-off-by: Patrick McHardy <kaber@trash.net>
#
diff -Nru a/net/sched/act_api.c b/net/sched/act_api.c
--- a/net/sched/act_api.c 2005-01-10 06:23:12 +01:00
+++ b/net/sched/act_api.c 2005-01-10 06:23:12 +01:00
@@ -463,31 +463,46 @@
return err;
}
-static int tcf_action_get_1(struct rtattr *rta, struct tc_action *a,
- struct nlmsghdr *n, u32 pid)
+static struct tc_action *
+tcf_action_get_1(struct rtattr *rta, struct nlmsghdr *n, u32 pid, int *err)
{
struct rtattr *tb[TCA_ACT_MAX+1];
+ struct tc_action *a;
int index;
- int err = 0;
+ *err = -EINVAL;
if (rtattr_parse(tb, TCA_ACT_MAX, RTA_DATA(rta), RTA_PAYLOAD(rta)) < 0)
- return -EINVAL;
+ return NULL;
if (tb[TCA_ACT_INDEX - 1] == NULL ||
RTA_PAYLOAD(tb[TCA_ACT_INDEX - 1]) < sizeof(index))
- return -EINVAL;
+ return NULL;
index = *(int *)RTA_DATA(tb[TCA_ACT_INDEX - 1]);
+ *err = -ENOMEM;
+ a = kmalloc(sizeof(struct tc_action), GFP_KERNEL);
+ if (a == NULL)
+ return NULL;
+ memset(a, 0, sizeof(struct tc_action));
+
+ *err = -EINVAL;
a->ops = tc_lookup_action(tb[TCA_ACT_KIND - 1]);
if (a->ops == NULL)
- return -EINVAL;
+ goto err_free;
if (a->ops->lookup == NULL)
- err = -EINVAL;
- else if (a->ops->lookup(a, index) == 0)
- err = -ENOENT;
+ goto err_mod;
+ *err = -ENOENT;
+ if (a->ops->lookup(a, index) == 0)
+ goto err_mod;
module_put(a->ops->owner);
- return err;
+ *err = 0;
+ return a;
+err_mod:
+ module_put(a->ops->owner);
+err_free:
+ kfree(a);
+ return NULL;
}
static void cleanup_a(struct tc_action *act)
@@ -606,7 +621,11 @@
for (i=0; i < TCA_ACT_MAX_PRIO; i++) {
if (tb[i] == NULL)
break;
- act = create_a(i+1);
+ act = tcf_action_get_1(tb[i], n, pid, &ret);
+ if (act == NULL)
+ goto rtattr_failure;
+ act->order = i+1;
+
if (a != NULL) {
a->next = act;
a = act;
@@ -615,13 +634,6 @@
if (a_s == NULL)
a_s = a;
-
- ret = tcf_action_get_1(tb[i], act, n, pid);
- if (ret < 0) {
- printk("tcf_action_get: failed to get!\n");
- ret = -EINVAL;
- goto rtattr_failure;
- }
}
if (event == RTM_GETACTION)
reply other threads:[~2005-01-10 19:38 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=41E2D9A8.9080003@trash.net \
--to=kaber@trash.net \
--cc=hadi@cyberus.ca \
--cc=netdev@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).