Commit 615d069d authored by Eric Dumazet's avatar Eric Dumazet Committed by Jakub Kicinski

llc: add net device refcount tracker

Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 66ce07f7
...@@ -38,6 +38,7 @@ struct llc_sock { ...@@ -38,6 +38,7 @@ struct llc_sock {
struct llc_addr laddr; /* lsap/mac pair */ struct llc_addr laddr; /* lsap/mac pair */
struct llc_addr daddr; /* dsap/mac pair */ struct llc_addr daddr; /* dsap/mac pair */
struct net_device *dev; /* device to send to remote */ struct net_device *dev; /* device to send to remote */
netdevice_tracker dev_tracker;
u32 copied_seq; /* head of yet unread data */ u32 copied_seq; /* head of yet unread data */
u8 retry_count; /* number of retries */ u8 retry_count; /* number of retries */
u8 ack_must_be_send; u8 ack_must_be_send;
......
...@@ -224,7 +224,7 @@ static int llc_ui_release(struct socket *sock) ...@@ -224,7 +224,7 @@ static int llc_ui_release(struct socket *sock)
} else { } else {
release_sock(sk); release_sock(sk);
} }
dev_put(llc->dev); dev_put_track(llc->dev, &llc->dev_tracker);
sock_put(sk); sock_put(sk);
llc_sk_free(sk); llc_sk_free(sk);
out: out:
...@@ -295,6 +295,7 @@ static int llc_ui_autobind(struct socket *sock, struct sockaddr_llc *addr) ...@@ -295,6 +295,7 @@ static int llc_ui_autobind(struct socket *sock, struct sockaddr_llc *addr)
llc->dev = dev_getfirstbyhwtype(&init_net, addr->sllc_arphrd); llc->dev = dev_getfirstbyhwtype(&init_net, addr->sllc_arphrd);
if (!llc->dev) if (!llc->dev)
goto out; goto out;
netdev_tracker_alloc(llc->dev, &llc->dev_tracker, GFP_KERNEL);
rc = -EUSERS; rc = -EUSERS;
llc->laddr.lsap = llc_ui_autoport(); llc->laddr.lsap = llc_ui_autoport();
if (!llc->laddr.lsap) if (!llc->laddr.lsap)
...@@ -362,7 +363,7 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen) ...@@ -362,7 +363,7 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen)
} else } else
llc->dev = dev_getbyhwaddr_rcu(&init_net, addr->sllc_arphrd, llc->dev = dev_getbyhwaddr_rcu(&init_net, addr->sllc_arphrd,
addr->sllc_mac); addr->sllc_mac);
dev_hold(llc->dev); dev_hold_track(llc->dev, &llc->dev_tracker, GFP_ATOMIC);
rcu_read_unlock(); rcu_read_unlock();
if (!llc->dev) if (!llc->dev)
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment