netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Krzysztof Mazur <krzysiek@podlesie.net>
To: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>,
	David Woodhouse <David.Woodhouse@intel.com>,
	davem@davemloft.net, Krzysztof Mazur <krzysiek@podlesie.net>
Subject: [PATCH v3 2/7] atm: add owner of push() callback to atmvcc
Date: Tue,  6 Nov 2012 23:16:57 +0100	[thread overview]
Message-ID: <1352240222-363-3-git-send-email-krzysiek@podlesie.net> (raw)
In-Reply-To: <1352240222-363-1-git-send-email-krzysiek@podlesie.net>

The atm is using atmvcc->push(vcc, NULL) callback to notify protocol
that vcc will be closed and protocol must detach from it. This callback
is usually used by protocol to decrement module usage count by module_put(),
but it leaves small window then module is still used after module_put().

Now the owner of push() callback is kept in atmvcc and
module_put(atmvcc->owner) is called after the protocol is detached from vcc.

Signed-off-by: Krzysztof Mazur <krzysiek@podlesie.net>
---
 include/linux/atmdev.h | 1 +
 net/atm/common.c       | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
index 06fd4bb..31c16c6 100644
--- a/include/linux/atmdev.h
+++ b/include/linux/atmdev.h
@@ -315,6 +315,7 @@ struct atm_vcc {
 	void		*dev_data;	/* per-device data */
 	void		*proto_data;	/* per-protocol data */
 	struct k_atm_aal_stats *stats;	/* pointer to AAL stats group */
+	struct module *owner;		/* owner of ->push function */
 	/* SVC part --- may move later ------------------------------------- */
 	short		itf;		/* interface number */
 	struct sockaddr_atmsvc local;
diff --git a/net/atm/common.c b/net/atm/common.c
index a0e4411..ea952b2 100644
--- a/net/atm/common.c
+++ b/net/atm/common.c
@@ -156,6 +156,7 @@ int vcc_create(struct net *net, struct socket *sock, int protocol, int family)
 	atomic_set(&sk->sk_rmem_alloc, 0);
 	vcc->push = NULL;
 	vcc->pop = NULL;
+	vcc->owner = NULL;
 	vcc->push_oam = NULL;
 	vcc->vpi = vcc->vci = 0; /* no VCI/VPI yet */
 	vcc->atm_options = vcc->aal_options = 0;
@@ -173,6 +174,7 @@ static void vcc_destroy_socket(struct sock *sk)
 	if (vcc->dev) {
 		if (vcc->push)
 			vcc->push(vcc, NULL); /* atmarpd has no push */
+		module_put(vcc->owner);
 		if (vcc->dev->ops->close)
 			vcc->dev->ops->close(vcc);
 
-- 
1.8.0.233.g54991f2

  parent reply	other threads:[~2012-11-06 22:16 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-06 22:16 [PATCH v3 0/7] pppoatm: fix multiple issues with pppoatm driver Krzysztof Mazur
2012-11-06 22:16 ` [PATCH v3 1/7] atm: detach protocol before closing vcc Krzysztof Mazur
2012-11-06 22:16 ` Krzysztof Mazur [this message]
2012-11-07 19:05   ` [PATCH v3 2/7] atm: add owner of push() callback to atmvcc chas williams - CONTRACTOR
2012-11-06 22:16 ` [PATCH v3 3/7] pppoatm: allow assign only on a connected socket Krzysztof Mazur
2012-11-06 22:16 ` [PATCH v3 4/7] pppoatm: fix module_put() race Krzysztof Mazur
2012-11-06 22:17 ` [PATCH v3 5/7] pppoatm: take ATM socket lock in pppoatm_send() Krzysztof Mazur
2012-11-06 22:57   ` Woodhouse, David
2012-11-06 22:17 ` [PATCH v3 6/7] pppoatm: don't send frames on not-ready vcc Krzysztof Mazur
2012-11-06 22:17 ` [PATCH v3 7/7] pppoatm: do not inline pppoatm_may_send() Krzysztof Mazur
2012-11-07 12:52 ` [PATCH v3 8/7] pppoatm: fix missing wakeup in pppoatm_send() David Woodhouse
2012-11-09 21:30   ` David Miller
2012-11-10  7:36     ` David Woodhouse
2012-11-10 18:38       ` David Miller
2012-11-10 20:23   ` Krzysztof Mazur
2012-11-10 21:02     ` David Woodhouse
2012-11-10 22:33       ` Krzysztof Mazur
2012-11-11  7:28     ` David Woodhouse
2012-11-11 11:04       ` Krzysztof Mazur
2012-11-11 11:39         ` David Woodhouse
2012-11-11 13:50           ` Krzysztof Mazur
2012-11-11 15:26             ` David Woodhouse
2012-11-11 16:12               ` Krzysztof Mazur
2012-11-11 17:03                 ` David Woodhouse
2012-11-11 18:49                   ` Krzysztof Mazur
2012-11-11 20:51                     ` David Woodhouse
2012-11-11 22:57                       ` Chas Williams (CONTRACTOR)
2012-11-27 13:27                         ` David Woodhouse
2012-11-27 15:23                           ` chas williams - CONTRACTOR
2012-11-28  0:48                             ` David Woodhouse
2012-11-28  8:12                               ` Krzysztof Mazur
2012-11-28  9:24                                 ` David Woodhouse
2012-11-28  9:58                                   ` Krzysztof Mazur
2012-11-28 10:19                                     ` David Woodhouse
2012-11-11 22:47         ` Chas Williams (CONTRACTOR)

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=1352240222-363-3-git-send-email-krzysiek@podlesie.net \
    --to=krzysiek@podlesie.net \
    --cc=David.Woodhouse@intel.com \
    --cc=chas@cmf.nrl.navy.mil \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).