public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] f2fs: Cast expression type to unsigned long in __count_extent_cache()
@ 2024-03-05  8:09 Roman Smirnov
  2024-03-06  1:48 ` Chao Yu
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Roman Smirnov @ 2024-03-05  8:09 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu
  Cc: Roman Smirnov, Sergey Shtylyov, Karina Yankevich,
	linux-f2fs-devel, linux-kernel, lvc-project

Cast expression type to unsigned long in __count_extent_cache()
to prevent integer overflow.

Found by Linux Verification Center (linuxtesting.org) with Svace.

Signed-off-by: Roman Smirnov <r.smirnov@omp.ru>
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 fs/f2fs/shrinker.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/f2fs/shrinker.c b/fs/f2fs/shrinker.c
index 83d6fb97dcae..bb86a06c5d5e 100644
--- a/fs/f2fs/shrinker.c
+++ b/fs/f2fs/shrinker.c
@@ -33,7 +33,7 @@ static unsigned long __count_extent_cache(struct f2fs_sb_info *sbi,
 {
 	struct extent_tree_info *eti = &sbi->extent_tree[type];
 
-	return atomic_read(&eti->total_zombie_tree) +
+	return (unsigned long)atomic_read(&eti->total_zombie_tree) +
 				atomic_read(&eti->total_ext_node);
 }
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-03-11 21:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-05  8:09 [PATCH] f2fs: Cast expression type to unsigned long in __count_extent_cache() Roman Smirnov
2024-03-06  1:48 ` Chao Yu
2024-03-06 17:50 ` [f2fs-dev] " patchwork-bot+f2fs
2024-03-10 17:46 ` David Laight
2024-03-11 20:37   ` Jaegeuk Kim
2024-03-11 21:19     ` David Laight

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox