All of lore.kernel.org
 help / color / mirror / Atom feed
From: liweihang <liweihang@huawei.com>
To: Zhu Yanjun <zyjzyj2000@gmail.com>
Cc: Doug Ledford <dledford@redhat.com>,
	Jason Gunthorpe <jgg@nvidia.com>,
	Leon Romanovsky <leon@kernel.org>,
	RDMA mailing list <linux-rdma@vger.kernel.org>,
	Linuxarm <linuxarm@huawei.com>,
	Faisal Latif <faisal.latif@intel.com>,
	Shiraz Saleem <shiraz.saleem@intel.com>
Subject: Re: [PATCH v2 for-next 12/17] RDMA/i40iw: Use refcount_t instead of atomic_t on refcount of i40iw_cqp_request
Date: Mon, 24 May 2021 01:50:54 +0000	[thread overview]
Message-ID: <d71b12bd9d2d4509a642cc5d3090ea83@huawei.com> (raw)
In-Reply-To: CAD=hENcvLGEYOSXqU-KsWLn1He4hWoZt0S29hG7bwmpwU6ZS=g@mail.gmail.com

On 2021/5/22 17:42, Zhu Yanjun wrote:
> On Fri, May 21, 2021 at 7:35 PM Weihang Li <liweihang@huawei.com> wrote:
>>
>> The refcount_t API will WARN on underflow and overflow of a reference
>> counter, and avoid use-after-free risks.
>>
>> Cc: Faisal Latif <faisal.latif@intel.com>
>> Cc: Shiraz Saleem <shiraz.saleem@intel.com>
>> Signed-off-by: Weihang Li <liweihang@huawei.com>
>> ---
>>  drivers/infiniband/hw/i40iw/i40iw.h       |  2 +-
>>  drivers/infiniband/hw/i40iw/i40iw_main.c  |  2 +-
>>  drivers/infiniband/hw/i40iw/i40iw_utils.c | 10 +++++-----
> 
> https://patchwork.kernel.org/project/linux-rdma/patch/20210520143809.819-22-shiraz.saleem@intel.com/
> 
> In this commit, i40iw will be removed. And this commit will be merged
> into upstream linux.
> Not sure if this commit makes sense.
> 

I see, changes on i40iw will be dropped from this series, thanks.

Weihang

>>  3 files changed, 7 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/infiniband/hw/i40iw/i40iw.h b/drivers/infiniband/hw/i40iw/i40iw.h
>> index be4094a..15c5dd6 100644
>> --- a/drivers/infiniband/hw/i40iw/i40iw.h
>> +++ b/drivers/infiniband/hw/i40iw/i40iw.h
>> @@ -137,7 +137,7 @@ struct i40iw_cqp_request {
>>         struct cqp_commands_info info;
>>         wait_queue_head_t waitq;
>>         struct list_head list;
>> -       atomic_t refcount;
>> +       refcount_t refcount;
>>         void (*callback_fcn)(struct i40iw_cqp_request*, u32);
>>         void *param;
>>         struct i40iw_cqp_compl_info compl_info;
>> diff --git a/drivers/infiniband/hw/i40iw/i40iw_main.c b/drivers/infiniband/hw/i40iw/i40iw_main.c
>> index b496f30..fc48555 100644
>> --- a/drivers/infiniband/hw/i40iw/i40iw_main.c
>> +++ b/drivers/infiniband/hw/i40iw/i40iw_main.c
>> @@ -1125,7 +1125,7 @@ static enum i40iw_status_code i40iw_alloc_local_mac_ipaddr_entry(struct i40iw_de
>>         }
>>
>>         /* increment refcount, because we need the cqp request ret value */
>> -       atomic_inc(&cqp_request->refcount);
>> +       refcount_inc(&cqp_request->refcount);
>>
>>         cqp_info = &cqp_request->info;
>>         cqp_info->cqp_cmd = OP_ALLOC_LOCAL_MAC_IPADDR_ENTRY;
>> diff --git a/drivers/infiniband/hw/i40iw/i40iw_utils.c b/drivers/infiniband/hw/i40iw/i40iw_utils.c
>> index 9ff825f..32ff432b 100644
>> --- a/drivers/infiniband/hw/i40iw/i40iw_utils.c
>> +++ b/drivers/infiniband/hw/i40iw/i40iw_utils.c
>> @@ -384,10 +384,10 @@ struct i40iw_cqp_request *i40iw_get_cqp_request(struct i40iw_cqp *cqp, bool wait
>>         }
>>
>>         if (wait) {
>> -               atomic_set(&cqp_request->refcount, 2);
>> +               refcount_set(&cqp_request->refcount, 2);
>>                 cqp_request->waiting = true;
>>         } else {
>> -               atomic_set(&cqp_request->refcount, 1);
>> +               refcount_set(&cqp_request->refcount, 1);
>>         }
>>         return cqp_request;
>>  }
>> @@ -424,7 +424,7 @@ void i40iw_free_cqp_request(struct i40iw_cqp *cqp, struct i40iw_cqp_request *cqp
>>  void i40iw_put_cqp_request(struct i40iw_cqp *cqp,
>>                            struct i40iw_cqp_request *cqp_request)
>>  {
>> -       if (atomic_dec_and_test(&cqp_request->refcount))
>> +       if (refcount_dec_and_test(&cqp_request->refcount))
>>                 i40iw_free_cqp_request(cqp, cqp_request);
>>  }
>>
>> @@ -445,7 +445,7 @@ static void i40iw_free_pending_cqp_request(struct i40iw_cqp *cqp,
>>         }
>>         i40iw_put_cqp_request(cqp, cqp_request);
>>         wait_event_timeout(iwdev->close_wq,
>> -                          !atomic_read(&cqp_request->refcount),
>> +                          !refcount_read(&cqp_request->refcount),
>>                            1000);
>>  }
>>
>> @@ -1005,7 +1005,7 @@ static void i40iw_cqp_manage_hmc_fcn_callback(struct i40iw_cqp_request *cqp_requ
>>
>>         if (hmcfcninfo && hmcfcninfo->callback_fcn) {
>>                 i40iw_debug(&iwdev->sc_dev, I40IW_DEBUG_HMC, "%s1\n", __func__);
>> -               atomic_inc(&cqp_request->refcount);
>> +               refcount_inc(&cqp_request->refcount);
>>                 work = &iwdev->virtchnl_w[hmcfcninfo->iw_vf_idx];
>>                 work->cqp_request = cqp_request;
>>                 INIT_WORK(&work->work, i40iw_cqp_manage_hmc_fcn_worker);
>> --
>> 2.7.4
>>
> 


  reply	other threads:[~2021-05-24  1:50 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-21  9:53 [PATCH v2 for-next 00/17] RDMA: Use refcount_t for reference counting Weihang Li
2021-05-21  9:53 ` [PATCH v2 for-next 01/17] RDMA/core: Use refcount_t instead of atomic_t on refcount of iwcm_id_private Weihang Li
2021-05-21  9:53 ` [PATCH v2 for-next 02/17] RDMA/core: Use refcount_t instead of atomic_t on refcount of iwpm_admin_data Weihang Li
2021-05-21  9:53 ` [PATCH v2 for-next 03/17] RDMA/core: Use refcount_t instead of atomic_t on refcount of ib_mad_snoop_private Weihang Li
2021-05-21  9:53 ` [PATCH v2 for-next 04/17] RDMA/core: Use refcount_t instead of atomic_t on refcount of mcast_member Weihang Li
2021-05-21  9:53 ` [PATCH v2 for-next 05/17] RDMA/core: Use refcount_t instead of atomic_t on refcount of mcast_port Weihang Li
2021-05-21  9:53 ` [PATCH v2 for-next 06/17] RDMA/core: Use refcount_t instead of atomic_t on refcount of mcast_group Weihang Li
2021-05-21  9:53 ` [PATCH v2 for-next 07/17] RDMA/core: Use refcount_t instead of atomic_t on refcount of ib_uverbs_device Weihang Li
2021-05-21  9:53 ` [PATCH v2 for-next 08/17] RDMA/hns: Use refcount_t instead of atomic_t for CQ reference counting Weihang Li
2021-05-21  9:53 ` [PATCH v2 for-next 09/17] RDMA/hns: Use refcount_t instead of atomic_t for SRQ " Weihang Li
2021-05-21  9:53 ` [PATCH v2 for-next 10/17] RDMA/hns: Use refcount_t instead of atomic_t for QP " Weihang Li
2021-05-21  9:53 ` [PATCH v2 for-next 11/17] RDMA/cxgb4: Use refcount_t instead of atomic_t for " Weihang Li
2021-05-21  9:53 ` [PATCH v2 for-next 12/17] RDMA/i40iw: Use refcount_t instead of atomic_t on refcount of i40iw_cqp_request Weihang Li
2021-05-22  9:41   ` Zhu Yanjun
2021-05-24  1:50     ` liweihang [this message]
2021-05-21  9:53 ` [PATCH v2 for-next 13/17] RDMA/i40iw: Use refcount_t instead of atomic_t on refcount of i40iw_cm_listener Weihang Li
2021-05-21  9:53 ` [PATCH v2 for-next 14/17] RDMA/i40iw: Use refcount_t instead of atomic_t on refcount of i40iw_puda_buf Weihang Li
2021-05-22  9:42   ` Zhu Yanjun
2021-05-21  9:53 ` [PATCH v2 for-next 15/17] RDMA/i40iw: Use refcount_t instead of atomic_t on refcount of i40iw_cm_node Weihang Li
2021-05-22  9:40   ` Zhu Yanjun
2021-05-21  9:53 ` [PATCH v2 for-next 16/17] RDMA/ipoib: Use refcount_t instead of atomic_t for reference counting Weihang Li
2021-05-21  9:53 ` [PATCH v2 for-next 17/17] RDMA/rdmavt: Use refcount_t instead of atomic_t on refcount of rvt_mcast Weihang Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d71b12bd9d2d4509a642cc5d3090ea83@huawei.com \
    --to=liweihang@huawei.com \
    --cc=dledford@redhat.com \
    --cc=faisal.latif@intel.com \
    --cc=jgg@nvidia.com \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=shiraz.saleem@intel.com \
    --cc=zyjzyj2000@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.