Skip to contentSkip to conversation

Coverity: zblock_reclaim_block(): Control flow issues

DISCUSSION coverity-bot 2 participants 2 messages Nov 17, 2022 – Nov 18, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hello!

This is an experimental semi-automated report about issues detected by Coverity from a scan of next-20221117 as part of the linux-next scan project:
https://scan.coverity.com/projects/linux-next-weekly-scan

You're getting this email because you were associated with the identified lines of code (noted below) that were touched by commits:

Wed Nov 16 16:19:12 2022 -0800
9097e28c25c8 ("mm: add zblock - new allocator for use via zpool API")

Coverity reported the following:

*** CID 1527349: Control flow issues (NO_EFFECT) mm/zblock.c:412 in zblock_reclaim_block()
406 unsigned long handle, block_type, slot;
407 int ret, i, reclaimed;
408

409     	/* start with list storing blocks with the worst compression and try
410     	 * to evict the first added (oldest) block in this list
411     	 */
vvv     CID 1527349:  Control flow issues  (NO_EFFECT)
vvv     This greater-than-or-equal-to-zero comparison of an unsigned value is always true. "block_type >= 0UL".
412     	for (block_type = ARRAY_SIZE(block_desc) - 1; block_type >= 0; --block_type) {
413     		list = &(pool->block_lists[block_type]);
414     		spin_lock(&list->lock);

415
416 /* find the oldest block in list */
417 block = list_last_entry(&list->head, struct zblock_block, block_node);

If this is a false positive, please let us know so we can mark it as such, or teach the Coverity rules to be smarter. If not, please make sure fixes get into linux-next. :) For patches fixing this, please include these lines (but double-check the "Fixes" first):

Addresses-Coverity-ID: 1527349 ("Control flow issues")

Fixes 9097e28c25c8 ("mm: add zblock - new allocator for use via zpool API")

Thanks for your attention!

Signature · 1 line
Coverity-bot
#1 lore raw
Quoted 19 lines · coverity-bot

Hello!

This is an experimental semi-automated report about issues detected by Coverity from a scan of next-20221117 as part of the linux-next scan project:
https://scan.coverity.com/projects/linux-next-weekly-scan

You're getting this email because you were associated with the identified lines of code (noted below) that were touched by commits:

Wed Nov 16 16:19:12 2022 -0800
9097e28c25c8 ("mm: add zblock - new allocator for use via zpool API")

Coverity reported the following:

*** CID 1527349: Control flow issues (NO_EFFECT) mm/zblock.c:412 in zblock_reclaim_block()
406 unsigned long handle, block_type, slot;
407 int ret, i, reclaimed;
408

Quoted 6 lines
409     	/* start with list storing blocks with the worst compression and try
410     	 * to evict the first added (oldest) block in this list
411     	 */
vvv     CID 1527349:  Control flow issues  (NO_EFFECT)
vvv     This greater-than-or-equal-to-zero comparison of an unsigned value is always true. "block_type >= 0UL".
412     	for (block_type = ARRAY_SIZE(block_desc) - 1; block_type >= 0; --block_type) {

This seems like a legit issue.

--
Gustavo

Quoted 19 lines

413 list = &(pool->block_lists[block_type]);
414 spin_lock(&list->lock);
415
416 /* find the oldest block in list */
417 block = list_last_entry(&list->head, struct zblock_block, block_node);

If this is a false positive, please let us know so we can mark it as such, or teach the Coverity rules to be smarter. If not, please make sure fixes get into linux-next. :) For patches fixing this, please include these lines (but double-check the "Fixes" first):

Addresses-Coverity-ID: 1527349 ("Control flow issues")

Fixes 9097e28c25c8 ("mm: add zblock - new allocator for use via zpool API")

Thanks for your attention!

Signature · 1 line
Coverity-bot