Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6342061ybi; Wed, 31 Jul 2019 12:36:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqxMSFGF8GLMwGYwgrRDyUiC9jC/1eGHDbI1+z1PA8IBqwAYbPvBchkTBSKlOToOj20UxdVJ X-Received: by 2002:a63:fd57:: with SMTP id m23mr50121695pgj.204.1564601778760; Wed, 31 Jul 2019 12:36:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564601778; cv=none; d=google.com; s=arc-20160816; b=L5rpZSILAvSxKCcDU+sx090CcQMfmn8kkRfM+vubnEtYlAEkzX6/Cz5ka/nSfcuk2V 8vt/D0sZznDeSUd3QALHJnEZleyBxaAklboiLa1VHj1HqQpR+N+HaWLcs7Kecl0p753J iliwaUzp8OZzuRCbHhiDkaK6l4K+xEOdmnI0tkHsQbZ8I5dH4g5IALmvOGHxsG+gbw4U oVrGRoPY+IVg7i2eSgLTtBKO/qK2iKwVGbIKg9KtXXc2yEVIySHOimsYdQDNKNSRvxvv uwYrZ8d7bPbPKfjBcSRLaTyevzcYiNla1bUB26ecDw/xIeRXRA7Dj/TYp3TD+mAdsA3d XOgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=97bUgywrkt2JLU+RvFdPEdGzMFShn8org1G3e5S/uHM=; b=u/Yj5D7mvquzXCOZiaVNo7WsLed8UBBywmann/47JmJi23NCJAFEBllkSnG+wpz+n3 1qVSRJba5J2EoP6DcqXDl3HGZQBsrmPuhTQzFzjZUFYv/wfPAS+aPZCE06Mr/mBOG7aD uQqyrzw9O7qjNqVDRBYLswz6Bt68DeBpqHX7t1OTmsTiYobYALPl9q0AOoauysvdsGH7 yX28dvNTd0bdkxIgNTdInLzsgf7DD3P/BPwZawCKQzyo2HPiL3fGo8o4TvB7G9wHZ8c7 c+Fr1fG6H7P4+tvlPjTui6AZGxYoRlTPg05TREBzkPL5CliO2kkxb43eoVTnw5LIF2tD JDVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=EyxO5+OX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d1si30546320pld.318.2019.07.31.12.36.03; Wed, 31 Jul 2019 12:36:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=EyxO5+OX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729627AbfGaRsl (ORCPT + 99 others); Wed, 31 Jul 2019 13:48:41 -0400 Received: from mail-yb1-f195.google.com ([209.85.219.195]:33886 "EHLO mail-yb1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726696AbfGaRsk (ORCPT ); Wed, 31 Jul 2019 13:48:40 -0400 Received: by mail-yb1-f195.google.com with SMTP id q5so12585390ybp.1 for ; Wed, 31 Jul 2019 10:48:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=97bUgywrkt2JLU+RvFdPEdGzMFShn8org1G3e5S/uHM=; b=EyxO5+OX8TZl1lHQ7ArUfTEeg/B9wHPTVkLsGhzJstlJnK1W+6N48SSdYdzrlE27RQ M/zfJM0+YSC1HLuF70QQJgla+28Eowzm+UsAUW3STgo+9yjifAssY2lyPVq2e+Q5FyKM 7SRhz9QqWLBiqNj5ktR/p1w1Gs/rtjbfM1HLg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=97bUgywrkt2JLU+RvFdPEdGzMFShn8org1G3e5S/uHM=; b=gY6foJ0UtdS9Y7bcH/dRbFdFAPLiSuKkRIZoW8NABGbnli0pSrVKSeZwSm34hhySXi yPgvBcznOGAHMMItsQjnusIwZ2J/ZCMKOHvTvqe9IuW+mTC1nlOKjpb/rPKqKflylTSA SMZkTpxFUrtijKpt5kV7m5bEHTFOwXmFTblrFQtfTQtVLryO5DBEkYoorSdgZSPEpogp +KjSP0XE7Vjy7D9ZWg+esc6JgWZn4tfhjGatxs7dbvctt7tsTRhI8bNQhc8NNDQuXBzL xDBlkQgsliSygvfLwfkVxziW7w+9CF61nFDT3kUwbL95vGmEWd5+ToHlo4SzG7fgRR2X JL8Q== X-Gm-Message-State: APjAAAVENlzaQdTxMhplwzFeIhkCabHMOnhQpwGKjJY9F/4kiCMtq+4Z vNCx8X3nTGSGMuhF6QJAaYqVnmViVtXpSSnvJDgUJNaY X-Received: by 2002:a25:7782:: with SMTP id s124mr38432904ybc.80.1564595319728; Wed, 31 Jul 2019 10:48:39 -0700 (PDT) MIME-Version: 1.0 References: <20190731122203.948-1-hslester96@gmail.com> In-Reply-To: From: Michael Chan Date: Wed, 31 Jul 2019 10:48:28 -0700 Message-ID: Subject: Re: [PATCH 1/2] bnxt_en: Use refcount_t for refcount To: Willem de Bruijn Cc: Chuhong Yuan , "David S . Miller" , Network Development , linux-kernel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 31, 2019 at 9:06 AM Willem de Bruijn wrote: > > On Wed, Jul 31, 2019 at 8:22 AM Chuhong Yuan wrote: > > > > refcount_t is better for reference counters since its > > implementation can prevent overflows. > > So convert atomic_t ref counters to refcount_t. > > > > Signed-off-by: Chuhong Yuan > > --- > > drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c | 8 ++++---- > > drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h | 2 +- > > 2 files changed, 5 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c > > index fc77caf0a076..eb7ed34639e2 100644 > > --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c > > +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c > > @@ -49,7 +49,7 @@ static int bnxt_register_dev(struct bnxt_en_dev *edev, int ulp_id, > > return -ENOMEM; > > } > > > > - atomic_set(&ulp->ref_count, 0); > > + refcount_set(&ulp->ref_count, 0); > > One feature of refcount_t is that it warns on refcount_inc from 0 to > detect possible use-after_free. It appears that that can trigger here? > I think that's right. We need to change the driver to start counting from 1 instead of 0 if we convert to refcount.