diff mbox series

[v4,for-next,03/12] RDMA/core: Use refcount_t instead of atomic_t on refcount of ib_mad_snoop_private

Message ID 1622194663-2383-4-git-send-email-liweihang@huawei.com (mailing list archive)
State Changes Requested
Headers show
Series RDMA: Use refcount_t for reference counting | expand

Commit Message

Weihang Li May 28, 2021, 9:37 a.m. UTC
The refcount_t API will WARN on underflow and overflow of a reference
counter, and avoid use-after-free risks.

Signed-off-by: Weihang Li <liweihang@huawei.com>
---
 drivers/infiniband/core/mad_priv.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jason Gunthorpe June 8, 2021, 6:04 p.m. UTC | #1
On Fri, May 28, 2021 at 05:37:34PM +0800, Weihang Li wrote:
> The refcount_t API will WARN on underflow and overflow of a reference
> counter, and avoid use-after-free risks.
> 
> Signed-off-by: Weihang Li <liweihang@huawei.com>
> ---
>  drivers/infiniband/core/mad_priv.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/core/mad_priv.h b/drivers/infiniband/core/mad_priv.h
> index 4aa16b3..25e573d 100644
> --- a/drivers/infiniband/core/mad_priv.h
> +++ b/drivers/infiniband/core/mad_priv.h
> @@ -115,7 +115,7 @@ struct ib_mad_snoop_private {
>  	struct ib_mad_qp_info *qp_info;
>  	int snoop_index;
>  	int mad_snoop_flags;
> -	atomic_t refcount;
> +	refcount_t refcount;
>  	struct completion comp;
>  };

Since this is never used I changed this to just delete it

Jason
Weihang Li June 9, 2021, 3:27 a.m. UTC | #2
On 2021/6/9 2:04, Jason Gunthorpe wrote:
> On Fri, May 28, 2021 at 05:37:34PM +0800, Weihang Li wrote:
>> The refcount_t API will WARN on underflow and overflow of a reference
>> counter, and avoid use-after-free risks.
>>
>> Signed-off-by: Weihang Li <liweihang@huawei.com>
>> ---
>>  drivers/infiniband/core/mad_priv.h | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/infiniband/core/mad_priv.h b/drivers/infiniband/core/mad_priv.h
>> index 4aa16b3..25e573d 100644
>> --- a/drivers/infiniband/core/mad_priv.h
>> +++ b/drivers/infiniband/core/mad_priv.h
>> @@ -115,7 +115,7 @@ struct ib_mad_snoop_private {
>>  	struct ib_mad_qp_info *qp_info;
>>  	int snoop_index;
>>  	int mad_snoop_flags;
>> -	atomic_t refcount;
>> +	refcount_t refcount;
>>  	struct completion comp;
>>  };
> 
> Since this is never used I changed this to just delete it
> 
> Jason
> 

Sure, thanks.

Weihang
diff mbox series

Patch

diff --git a/drivers/infiniband/core/mad_priv.h b/drivers/infiniband/core/mad_priv.h
index 4aa16b3..25e573d 100644
--- a/drivers/infiniband/core/mad_priv.h
+++ b/drivers/infiniband/core/mad_priv.h
@@ -115,7 +115,7 @@  struct ib_mad_snoop_private {
 	struct ib_mad_qp_info *qp_info;
 	int snoop_index;
 	int mad_snoop_flags;
-	atomic_t refcount;
+	refcount_t refcount;
 	struct completion comp;
 };