2022-03-17 05:59:00

by Zhen Lei

[permalink] [raw]
Subject: [PATCH] locking/refcount: Use REFCOUNT_WARN() to simplify code

To avoid the check "new > val" appears twice, and make the style
consistent with that in refcount_warn_saturate().

Signed-off-by: Zhen Lei <[email protected]>
---
lib/refcount.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/refcount.c b/lib/refcount.c
index a207a8f22b3ca35..d36aa3fa728f53b 100644
--- a/lib/refcount.c
+++ b/lib/refcount.c
@@ -84,7 +84,7 @@ bool refcount_dec_not_one(refcount_t *r)

new = val - 1;
if (new > val) {
- WARN_ONCE(new > val, "refcount_t: underflow; use-after-free.\n");
+ REFCOUNT_WARN("underflow; use-after-free");
return true;
}

--
2.25.1


2022-04-05 02:51:55

by Will Deacon

[permalink] [raw]
Subject: Re: [PATCH] locking/refcount: Use REFCOUNT_WARN() to simplify code

On Wed, Mar 16, 2022 at 08:51:14PM +0800, Zhen Lei wrote:
> To avoid the check "new > val" appears twice, and make the style
> consistent with that in refcount_warn_saturate().
>
> Signed-off-by: Zhen Lei <[email protected]>
> ---
> lib/refcount.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/refcount.c b/lib/refcount.c
> index a207a8f22b3ca35..d36aa3fa728f53b 100644
> --- a/lib/refcount.c
> +++ b/lib/refcount.c
> @@ -84,7 +84,7 @@ bool refcount_dec_not_one(refcount_t *r)
>
> new = val - 1;
> if (new > val) {
> - WARN_ONCE(new > val, "refcount_t: underflow; use-after-free.\n");
> + REFCOUNT_WARN("underflow; use-after-free");
> return true;
> }

Acked-by: Will Deacon <[email protected]>

Will

2022-11-02 10:06:09

by Zhen Lei

[permalink] [raw]
Subject: Re: [PATCH] locking/refcount: Use REFCOUNT_WARN() to simplify code



On 2022/4/4 17:31, Will Deacon wrote:
> On Wed, Mar 16, 2022 at 08:51:14PM +0800, Zhen Lei wrote:
>> To avoid the check "new > val" appears twice, and make the style
>> consistent with that in refcount_warn_saturate().
>>
>> Signed-off-by: Zhen Lei <[email protected]>
>> ---
>> lib/refcount.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/lib/refcount.c b/lib/refcount.c
>> index a207a8f22b3ca35..d36aa3fa728f53b 100644
>> --- a/lib/refcount.c
>> +++ b/lib/refcount.c
>> @@ -84,7 +84,7 @@ bool refcount_dec_not_one(refcount_t *r)
>>
>> new = val - 1;
>> if (new > val) {
>> - WARN_ONCE(new > val, "refcount_t: underflow; use-after-free.\n");
>> + REFCOUNT_WARN("underflow; use-after-free");
>> return true;
>> }
>
> Acked-by: Will Deacon <[email protected]>

Can anyone pick up this patch? It seems to have been forgotten.

>
> Will
> .
>

--
Regards,
Zhen Lei