linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] file: Added pointer check
@ 2022-12-06  9:32 Denis Arefev
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Arefev @ 2022-12-06  9:32 UTC (permalink / raw)
  To: David Sterba; +Cc: linux-fsdevel, linux-kernel, lvc-project, trufanov, vfh

Return value of a function 'affs_bread' is dereferenced at file.c:970
without checking for null, but it is usually checked for this function.

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

Signed-off-by: Denis Arefev <arefev@swemel.ru>
---
 fs/affs/file.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/affs/file.c b/fs/affs/file.c
index d91b0133d95d..4566fa767f65 100644
--- a/fs/affs/file.c
+++ b/fs/affs/file.c
@@ -963,6 +963,8 @@ affs_truncate(struct inode *inode)
 
 	while (ext_key) {
 		ext_bh = affs_bread(sb, ext_key);
+		if (!ext_bh)
+			break;
 		size = AFFS_SB(sb)->s_hashsize;
 		if (size > blkcnt - blk)
 			size = blkcnt - blk;
-- 
2.25.1


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

* [PATCH] file: Added pointer check
@ 2022-11-15 13:03 Denis Arefev
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Arefev @ 2022-11-15 13:03 UTC (permalink / raw)
  To: David Sterba
  Cc: linux-fsdevel, linux-kernel, Alexey Khoroshilov, ldv-project,
	trufanov, vfh

Return value of a function 'affs_bread' is dereferenced at file.c:970
without checking for null, but it is usually checked for this function.

Signed-off-by: Denis Arefev <arefev@swemel.ru>
---
 fs/affs/file.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/affs/file.c b/fs/affs/file.c
index d91b0133d95d..4566fa767f65 100644
--- a/fs/affs/file.c
+++ b/fs/affs/file.c
@@ -963,6 +963,8 @@ affs_truncate(struct inode *inode)
 
 	while (ext_key) {
 		ext_bh = affs_bread(sb, ext_key);
+		if (!ext_bh)
+			break;
 		size = AFFS_SB(sb)->s_hashsize;
 		if (size > blkcnt - blk)
 			size = blkcnt - blk;
-- 
2.25.1


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

end of thread, other threads:[~2022-12-06  9:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-06  9:32 [PATCH] file: Added pointer check Denis Arefev
  -- strict thread matches above, loose matches on Subject: below --
2022-11-15 13:03 Denis Arefev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).