Skip to content

Commit ec809bd

Browse files
Krzysztof MazurDavid Woodhouse
authored andcommitted
atm: add owner of push() callback to atmvcc
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> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> Acked-by: Chas Williams <chas@cmf.nrl.navy.mil>
1 parent ae088d6 commit ec809bd

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

‎include/linux/atmdev.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ struct atm_vcc {
106106
void *dev_data; /* per-device data */
107107
void *proto_data; /* per-protocol data */
108108
struct k_atm_aal_stats *stats; /* pointer to AAL stats group */
109+
struct module *owner; /* owner of ->push function */
109110
/* SVC part --- may move later ------------------------------------- */
110111
short itf; /* interface number */
111112
struct sockaddr_atmsvc local;

‎net/atm/common.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ int vcc_create(struct net *net, struct socket *sock, int protocol, int family)
156156
atomic_set(&sk->sk_rmem_alloc, 0);
157157
vcc->push = NULL;
158158
vcc->pop = NULL;
159+
vcc->owner = NULL;
159160
vcc->push_oam = NULL;
160161
vcc->vpi = vcc->vci = 0; /* no VCI/VPI yet */
161162
vcc->atm_options = vcc->aal_options = 0;
@@ -175,6 +176,7 @@ static void vcc_destroy_socket(struct sock *sk)
175176
vcc->dev->ops->close(vcc);
176177
if (vcc->push)
177178
vcc->push(vcc, NULL); /* atmarpd has no push */
179+
module_put(vcc->owner);
178180

179181
while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) {
180182
atm_return(vcc, skb->truesize);

0 commit comments

Comments
 (0)