lkml.org 
[lkml]   [2021]   [Jul]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] cxgb3: Convert from atomic_t to refcount_t on l2t_entry->refcnt
On Sat, Jul 17, 2021 at 06:16:15PM +0800, Xiyu Yang wrote:
> refcount_t type and corresponding API can protect refcounters from
> accidental underflow and overflow and further use-after-free situations.
>
> Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
> Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
> ---
> drivers/net/ethernet/chelsio/cxgb3/l2t.c | 15 ++++++++-------
> drivers/net/ethernet/chelsio/cxgb3/l2t.h | 10 +++++++---
> 2 files changed, 15 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.c b/drivers/net/ethernet/chelsio/cxgb3/l2t.c
> index 9749d1239f58..0f2a47bc20d8 100644
> --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.c
> +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.c
> @@ -225,10 +225,11 @@ static struct l2t_entry *alloc_l2e(struct l2t_data *d)
>
> /* there's definitely a free entry */
> for (e = d->rover, end = &d->l2tab[d->nentries]; e != end; ++e)
> - if (atomic_read(&e->refcnt) == 0)
> + if (refcount_read(&e->refcnt) == 0)

All those atomic_t to refcount_t patches can't be right, refcount_t can't be 0.

Thanks

\
 
 \ /
  Last update: 2021-07-18 12:43    [W:0.068 / U:1.232 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site