diff options
author | Eric Dumazet <edumazet@google.com> | 2017-08-18 12:08:07 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-08-18 15:14:07 -0700 |
commit | 9620fef27ed2cdb37bf6fd028f32bea2ef5119a8 (patch) | |
tree | 7d4b243d0f353b98fd379d0d6ad800d734506e30 /net/ipv4/fib_semantics.c | |
parent | 633cefe390e59e9449dc88707235e57ac76b5c38 (diff) | |
download | op-kernel-dev-9620fef27ed2cdb37bf6fd028f32bea2ef5119a8.zip op-kernel-dev-9620fef27ed2cdb37bf6fd028f32bea2ef5119a8.tar.gz |
ipv4: convert dst_metrics.refcnt from atomic_t 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.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/fib_semantics.c')
-rw-r--r-- | net/ipv4/fib_semantics.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c index d521caf..394d800 100644 --- a/net/ipv4/fib_semantics.c +++ b/net/ipv4/fib_semantics.c @@ -220,7 +220,7 @@ static void free_fib_info_rcu(struct rcu_head *head) } endfor_nexthops(fi); m = fi->fib_metrics; - if (m != &dst_default_metrics && atomic_dec_and_test(&m->refcnt)) + if (m != &dst_default_metrics && refcount_dec_and_test(&m->refcnt)) kfree(m); kfree(fi); } @@ -1090,7 +1090,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg, kfree(fi); return ERR_PTR(err); } - atomic_set(&fi->fib_metrics->refcnt, 1); + refcount_set(&fi->fib_metrics->refcnt, 1); } else { fi->fib_metrics = (struct dst_metrics *)&dst_default_metrics; } |