* [PATCH] badblocks: Fix a nonsense WARN_ON() which checks whether a u64 variable < 0
@ 2025-03-09 16:05 colyli
2025-03-09 16:12 ` Fwd: " Coly Li
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: colyli @ 2025-03-09 16:05 UTC (permalink / raw)
To: linux-block; +Cc: axboe, Coly Li, Dan Carpenter
From: Coly Li <colyli@kernel.org>
In _badblocks_check(), there are lines of code like this,
1246 sectors -= len;
[snipped]
1251 WARN_ON(sectors < 0);
The WARN_ON() at line 1257 doesn't make sense because sectors is
unsigned long long type and never to be <0.
Fix it by checking directly checking whether sectors is less than len.
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Coly Li <colyli@kernel.org>
---
block/badblocks.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/block/badblocks.c b/block/badblocks.c
index 673ef068423a..ece64e76fe8f 100644
--- a/block/badblocks.c
+++ b/block/badblocks.c
@@ -1242,14 +1242,15 @@ static int _badblocks_check(struct badblocks *bb, sector_t s, sector_t sectors,
len = sectors;
update_sectors:
+ /* This situation should never happen */
+ WARN_ON(sectors < len);
+
s += len;
sectors -= len;
if (sectors > 0)
goto re_check;
- WARN_ON(sectors < 0);
-
if (unacked_badblocks > 0)
rv = -1;
else if (acked_badblocks > 0)
--
2.47.2
^ permalink raw reply related [flat|nested] 8+ messages in thread* Fwd: [PATCH] badblocks: Fix a nonsense WARN_ON() which checks whether a u64 variable < 0
2025-03-09 16:05 [PATCH] badblocks: Fix a nonsense WARN_ON() which checks whether a u64 variable < 0 colyli
@ 2025-03-09 16:12 ` Coly Li
2025-03-10 13:42 ` Jens Axboe
2025-03-10 2:06 ` Yu Kuai
2025-03-10 13:50 ` Jens Axboe
2 siblings, 1 reply; 8+ messages in thread
From: Coly Li @ 2025-03-09 16:12 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Dan Carpenter
Hi Jens,
Could you please take a look at it and pick this patch into the for-6.15/block branch? The patch is generated based on the for-6.15/block branch.
Thanks in advance.
Coly Li
> From: Coly Li <colyli@kernel.org>
>
> In _badblocks_check(), there are lines of code like this,
> 1246 sectors -= len;
> [snipped]
> 1251 WARN_ON(sectors < 0);
>
> The WARN_ON() at line 1257 doesn't make sense because sectors is
> unsigned long long type and never to be <0.
>
> Fix it by checking directly checking whether sectors is less than len.
>
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Signed-off-by: Coly Li <colyli@kernel.org>
> ---
> block/badblocks.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/block/badblocks.c b/block/badblocks.c
> index 673ef068423a..ece64e76fe8f 100644
> --- a/block/badblocks.c
> +++ b/block/badblocks.c
> @@ -1242,14 +1242,15 @@ static int _badblocks_check(struct badblocks *bb, sector_t s, sector_t sectors,
> len = sectors;
>
> update_sectors:
> + /* This situation should never happen */
> + WARN_ON(sectors < len);
> +
> s += len;
> sectors -= len;
>
> if (sectors > 0)
> goto re_check;
>
> - WARN_ON(sectors < 0);
> -
> if (unacked_badblocks > 0)
> rv = -1;
> else if (acked_badblocks > 0)
> --
> 2.47.2
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Fwd: [PATCH] badblocks: Fix a nonsense WARN_ON() which checks whether a u64 variable < 0
2025-03-09 16:12 ` Fwd: " Coly Li
@ 2025-03-10 13:42 ` Jens Axboe
2025-03-10 13:44 ` Coly Li
0 siblings, 1 reply; 8+ messages in thread
From: Jens Axboe @ 2025-03-10 13:42 UTC (permalink / raw)
To: Coly Li; +Cc: linux-block, Dan Carpenter
On 3/9/25 10:12 AM, Coly Li wrote:
> Hi Jens,
>
> Could you please take a look at it and pick this patch into the for-6.15/block branch? The patch is generated based on the for-6.15/block branch.
Just a heads-up - you don't need to send these emails outside of
just sending the patch, I do get the patches. If I didn't, then that'd
be a problem. If you feel patches need extra context, then just do a
cover letter for them.
--
Jens Axboe
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] badblocks: Fix a nonsense WARN_ON() which checks whether a u64 variable < 0
2025-03-10 13:42 ` Jens Axboe
@ 2025-03-10 13:44 ` Coly Li
2025-03-10 13:49 ` Jens Axboe
0 siblings, 1 reply; 8+ messages in thread
From: Coly Li @ 2025-03-10 13:44 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Dan Carpenter
> 2025年3月10日 21:42,Jens Axboe <axboe@kernel.dk> 写道:
>
> On 3/9/25 10:12 AM, Coly Li wrote:
>> Hi Jens,
>>
>> Could you please take a look at it and pick this patch into the for-6.15/block branch? The patch is generated based on the for-6.15/block branch.
>
> Just a heads-up - you don't need to send these emails outside of
> just sending the patch, I do get the patches. If I didn't, then that'd
> be a problem. If you feel patches need extra context, then just do a
> cover letter for them.
So if you are the receiver of the patch email, then I don’t need to worry that you will treat it as a normal patch for review. Can I take this as a rule?
Thanks.
Coly Li
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] badblocks: Fix a nonsense WARN_ON() which checks whether a u64 variable < 0
2025-03-10 13:44 ` Coly Li
@ 2025-03-10 13:49 ` Jens Axboe
2025-03-10 13:50 ` Coly Li
0 siblings, 1 reply; 8+ messages in thread
From: Jens Axboe @ 2025-03-10 13:49 UTC (permalink / raw)
To: Coly Li; +Cc: linux-block, Dan Carpenter
On 3/10/25 7:44 AM, Coly Li wrote:
>
>
>> 2025?3?10? 21:42?Jens Axboe <axboe@kernel.dk> ???
>>
>> On 3/9/25 10:12 AM, Coly Li wrote:
>>> Hi Jens,
>>>
>>> Could you please take a look at it and pick this patch into the for-6.15/block branch? The patch is generated based on the for-6.15/block branch.
>>
>> Just a heads-up - you don't need to send these emails outside of
>> just sending the patch, I do get the patches. If I didn't, then that'd
>> be a problem. If you feel patches need extra context, then just do a
>> cover letter for them.
>
> So if you are the receiver of the patch email, then I don?t need to
> worry that you will treat it as a normal patch for review. Can I take
> this as a rule?
Yes of course - I don't think I've ever seen anyone else send out a
patch with a followup a few minutes later to apply it. Just send out the
patch, and it should get applied. If it doesn't after a week or
whatever, then feel free to send a reminder. But a reminder to apply it
a few min after the original patch is a bit unusual and odd.
--
Jens Axboe
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] badblocks: Fix a nonsense WARN_ON() which checks whether a u64 variable < 0
2025-03-10 13:49 ` Jens Axboe
@ 2025-03-10 13:50 ` Coly Li
0 siblings, 0 replies; 8+ messages in thread
From: Coly Li @ 2025-03-10 13:50 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Dan Carpenter
> 2025年3月10日 21:49,Jens Axboe <axboe@kernel.dk> 写道:
>
> On 3/10/25 7:44 AM, Coly Li wrote:
>>
>>
>>> 2025?3?10? 21:42?Jens Axboe <axboe@kernel.dk> ???
>>>
>>> On 3/9/25 10:12 AM, Coly Li wrote:
>>>> Hi Jens,
>>>>
>>>> Could you please take a look at it and pick this patch into the for-6.15/block branch? The patch is generated based on the for-6.15/block branch.
>>>
>>> Just a heads-up - you don't need to send these emails outside of
>>> just sending the patch, I do get the patches. If I didn't, then that'd
>>> be a problem. If you feel patches need extra context, then just do a
>>> cover letter for them.
>>
>> So if you are the receiver of the patch email, then I don?t need to
>> worry that you will treat it as a normal patch for review. Can I take
>> this as a rule?
>
> Yes of course - I don't think I've ever seen anyone else send out a
> patch with a followup a few minutes later to apply it. Just send out the
> patch, and it should get applied. If it doesn't after a week or
> whatever, then feel free to send a reminder. But a reminder to apply it
> a few min after the original patch is a bit unusual and odd.
Copied. So normally I will not send a following email to explain the extra information. If it is necessary, I will compose a cover letter.
Thanks for the notice.
Coly Li
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] badblocks: Fix a nonsense WARN_ON() which checks whether a u64 variable < 0
2025-03-09 16:05 [PATCH] badblocks: Fix a nonsense WARN_ON() which checks whether a u64 variable < 0 colyli
2025-03-09 16:12 ` Fwd: " Coly Li
@ 2025-03-10 2:06 ` Yu Kuai
2025-03-10 13:50 ` Jens Axboe
2 siblings, 0 replies; 8+ messages in thread
From: Yu Kuai @ 2025-03-10 2:06 UTC (permalink / raw)
To: colyli, linux-block; +Cc: axboe, Dan Carpenter, yukuai (C)
在 2025/03/10 0:05, colyli@kernel.org 写道:
> From: Coly Li <colyli@kernel.org>
>
> In _badblocks_check(), there are lines of code like this,
> 1246 sectors -= len;
> [snipped]
> 1251 WARN_ON(sectors < 0);
>
> The WARN_ON() at line 1257 doesn't make sense because sectors is
> unsigned long long type and never to be <0.
>
> Fix it by checking directly checking whether sectors is less than len.
>
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Signed-off-by: Coly Li <colyli@kernel.org>
> ---
> block/badblocks.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
LGTM
Reviewed-by: Yu Kuai <yukuai3@huawei.com>
> diff --git a/block/badblocks.c b/block/badblocks.c
> index 673ef068423a..ece64e76fe8f 100644
> --- a/block/badblocks.c
> +++ b/block/badblocks.c
> @@ -1242,14 +1242,15 @@ static int _badblocks_check(struct badblocks *bb, sector_t s, sector_t sectors,
> len = sectors;
>
> update_sectors:
> + /* This situation should never happen */
> + WARN_ON(sectors < len);
> +
> s += len;
> sectors -= len;
>
> if (sectors > 0)
> goto re_check;
>
> - WARN_ON(sectors < 0);
> -
> if (unacked_badblocks > 0)
> rv = -1;
> else if (acked_badblocks > 0)
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] badblocks: Fix a nonsense WARN_ON() which checks whether a u64 variable < 0
2025-03-09 16:05 [PATCH] badblocks: Fix a nonsense WARN_ON() which checks whether a u64 variable < 0 colyli
2025-03-09 16:12 ` Fwd: " Coly Li
2025-03-10 2:06 ` Yu Kuai
@ 2025-03-10 13:50 ` Jens Axboe
2 siblings, 0 replies; 8+ messages in thread
From: Jens Axboe @ 2025-03-10 13:50 UTC (permalink / raw)
To: linux-block, colyli; +Cc: Dan Carpenter
On Sun, 09 Mar 2025 12:05:56 -0400, colyli@kernel.org wrote:
> In _badblocks_check(), there are lines of code like this,
> 1246 sectors -= len;
> [snipped]
> 1251 WARN_ON(sectors < 0);
>
> The WARN_ON() at line 1257 doesn't make sense because sectors is
> unsigned long long type and never to be <0.
>
> [...]
Applied, thanks!
[1/1] badblocks: Fix a nonsense WARN_ON() which checks whether a u64 variable < 0
commit: 7e76336e14de9a2b67af96012ddd46c5676cf340
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-03-10 14:28 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-09 16:05 [PATCH] badblocks: Fix a nonsense WARN_ON() which checks whether a u64 variable < 0 colyli
2025-03-09 16:12 ` Fwd: " Coly Li
2025-03-10 13:42 ` Jens Axboe
2025-03-10 13:44 ` Coly Li
2025-03-10 13:49 ` Jens Axboe
2025-03-10 13:50 ` Coly Li
2025-03-10 2:06 ` Yu Kuai
2025-03-10 13:50 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox