summaryrefslogtreecommitdiffstats
path: root/drivers/vhost/net.c
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2017-09-01 01:48:22 +0200
committerDavid S. Miller <davem@davemloft.net>2017-09-02 05:22:03 +0200
commitc1d1b437816f0afa99202be3cb650c9d174667bc (patch)
tree14ee9ec0f2e759bb237b2a010aa56989874cc054 /drivers/vhost/net.c
parentnet: prepare (struct ubuf_info)->refcnt conversion (diff)
downloadlinux-c1d1b437816f0afa99202be3cb650c9d174667bc.tar.xz
linux-c1d1b437816f0afa99202be3cb650c9d174667bc.zip
net: convert (struct ubuf_info)->refcnt to refcount_t
refcount_t type and corresponding API should be used instead of atomic_t when the variable is used as a reference counter. This allows to avoid accidental refcounter overflows that might lead to use-after-free situations. v2: added the change in drivers/vhost/net.c as spotted by Willem. Signed-off-by: Eric Dumazet <edumazet@google.com> Acked-by: Willem de Bruijn <willemb@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/vhost/net.c')
-rw-r--r--drivers/vhost/net.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index ba08b78ed630..8d2bcae53a2e 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -533,7 +533,7 @@ static void handle_tx(struct vhost_net *net)
ubuf->callback = vhost_zerocopy_callback;
ubuf->ctx = nvq->ubufs;
ubuf->desc = nvq->upend_idx;
- atomic_set(&ubuf->refcnt, 1);
+ refcount_set(&ubuf->refcnt, 1);
msg.msg_control = ubuf;
msg.msg_controllen = sizeof(ubuf);
ubufs = nvq->ubufs;