From: "Ignacy Gawędzki" <ignacy.gawedzki@green-communications.fr>
To: netdev@vger.kernel.org
Subject: [PATCH net] ematch: Fix auto-loading of ematch modules.
Date: Mon, 16 Feb 2015 19:13:15 +0100 [thread overview]
Message-ID: <20150216181315.GA15280@zenon.in.qult.net> (raw)
In-Reply-To: <20150216150329.GB16798@zenon.in.qult.net>
In tcf_em_validate(), when calling tcf_em_lookup(), don't put the resulting
pointer directly into em->ops, if the function is to possibly return -EAGAIN
after module auto-loading. Otherwise, module_put() will be called by
tcf_em_tree_destroy() on em->ops->owner, while it has already been called by
tcf_em_validate() before return.
Signed-off-by: Ignacy Gawędzki <ignacy.gawedzki@green-communications.fr>
---
net/sched/ematch.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/net/sched/ematch.c b/net/sched/ematch.c
index 6742200..39fbe2f 100644
--- a/net/sched/ematch.c
+++ b/net/sched/ematch.c
@@ -176,6 +176,7 @@ static int tcf_em_validate(struct tcf_proto *tp,
{
int err = -EINVAL;
struct tcf_ematch_hdr *em_hdr = nla_data(nla);
+ struct tcf_ematch_ops *em_ops;
int data_len = nla_len(nla) - sizeof(*em_hdr);
void *data = (void *) em_hdr + sizeof(*em_hdr);
struct net *net = dev_net(qdisc_dev(tp->q));
@@ -213,27 +214,29 @@ static int tcf_em_validate(struct tcf_proto *tp,
* here. Be aware, the destroy function assumes that the
* module is held if the ops field is non zero.
*/
- em->ops = tcf_em_lookup(em_hdr->kind);
+ em_ops = tcf_em_lookup(em_hdr->kind);
- if (em->ops == NULL) {
+ if (em_ops == NULL) {
err = -ENOENT;
#ifdef CONFIG_MODULES
__rtnl_unlock();
request_module("ematch-kind-%u", em_hdr->kind);
rtnl_lock();
- em->ops = tcf_em_lookup(em_hdr->kind);
- if (em->ops) {
+ em_ops = tcf_em_lookup(em_hdr->kind);
+ if (em_ops) {
/* We dropped the RTNL mutex in order to
* perform the module load. Tell the caller
* to replay the request.
*/
- module_put(em->ops->owner);
+ module_put(em_ops->owner);
err = -EAGAIN;
}
#endif
goto errout;
}
+ em->ops = em_ops;
+
/* ematch module provides expected length of data, so we
* can do a basic sanity check.
*/
--
2.1.0
next prev parent reply other threads:[~2015-02-16 18:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-16 10:59 Attempt to auto-load em_cmp.ko results in negative module refcnt Ignacy Gawedzki
2015-02-16 15:03 ` Ignacy Gawedzki
2015-02-16 18:13 ` Ignacy Gawędzki [this message]
2015-02-16 18:36 ` [PATCH net] ematch: Fix auto-loading of ematch modules Cong Wang
2015-02-16 18:50 ` Ignacy Gawędzki
2015-02-17 18:00 ` Cong Wang
2015-02-17 19:15 ` [PATCH net v2] " Ignacy Gawędzki
2015-02-18 5:17 ` Cong Wang
2015-02-20 20:31 ` David Miller
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=20150216181315.GA15280@zenon.in.qult.net \
--to=ignacy.gawedzki@green-communications.fr \
--cc=netdev@vger.kernel.org \
/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