linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fs: affs: fix a NULL pointer dereference
@ 2019-03-15  7:42 Kangjie Lu
  2019-03-21 14:45 ` David Sterba
  0 siblings, 1 reply; 6+ messages in thread
From: Kangjie Lu @ 2019-03-15  7:42 UTC (permalink / raw)
  To: kjlu; +Cc: pakki001, David Sterba, linux-fsdevel, linux-kernel

If affs_bread fails, do not use ext_bh to avoid NULL pointer
 dereference

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
 fs/affs/file.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/affs/file.c b/fs/affs/file.c
index a85817f54483..29cbc8eda085 100644
--- a/fs/affs/file.c
+++ b/fs/affs/file.c
@@ -941,8 +941,10 @@ affs_truncate(struct inode *inode)
 		size = AFFS_SB(sb)->s_hashsize;
 		if (size > blkcnt - blk)
 			size = blkcnt - blk;
-		for (i = 0; i < size; i++, blk++)
-			affs_free_block(sb, be32_to_cpu(AFFS_BLOCK(sb, ext_bh, i)));
+		if (ext_bh) {
+			for (i = 0; i < size; i++, blk++)
+				affs_free_block(sb, be32_to_cpu(AFFS_BLOCK(sb, ext_bh, i)));
+		}
 		affs_free_block(sb, ext_key);
 		ext_key = be32_to_cpu(AFFS_TAIL(sb, ext_bh)->extension);
 		affs_brelse(ext_bh);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [PATCH] fs: affs: fix a NULL pointer dereference
@ 2019-03-14  7:46 Kangjie Lu
  2019-03-14 14:51 ` kbuild test robot
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Kangjie Lu @ 2019-03-14  7:46 UTC (permalink / raw)
  To: kjlu; +Cc: pakki001, David Sterba, linux-fsdevel, linux-kernel

If affs_bread fails, do not use ext_bh to avoid NULL pointer
 dereference

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
 fs/affs/file.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/fs/affs/file.c b/fs/affs/file.c
index a85817f54483..45b96faa40f1 100644
--- a/fs/affs/file.c
+++ b/fs/affs/file.c
@@ -835,7 +835,7 @@ void
 affs_truncate(struct inode *inode)
 {
 	struct super_block *sb = inode->i_sb;
-	u32 ext, ext_key;
+	u32 ext, ext_key, ext_bk;
 	u32 last_blk, blkcnt, blk;
 	u32 size;
 	struct buffer_head *ext_bh;
@@ -941,8 +941,12 @@ affs_truncate(struct inode *inode)
 		size = AFFS_SB(sb)->s_hashsize;
 		if (size > blkcnt - blk)
 			size = blkcnt - blk;
-		for (i = 0; i < size; i++, blk++)
-			affs_free_block(sb, be32_to_cpu(AFFS_BLOCK(sb, ext_bh, i)));
+		if (ext_bh) {
+			for (i = 0; i < size; i++, blk++) {
+				ext_bk = AFFS_BLOCK(sb, ext_bh, i);
+				affs_free_block(sb, be32_to_cpu(ext_bk));
+			}
+		}
 		affs_free_block(sb, ext_key);
 		ext_key = be32_to_cpu(AFFS_TAIL(sb, ext_bh)->extension);
 		affs_brelse(ext_bh);
-- 
2.17.1


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

end of thread, other threads:[~2019-03-21 14:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-15  7:42 [PATCH] fs: affs: fix a NULL pointer dereference Kangjie Lu
2019-03-21 14:45 ` David Sterba
  -- strict thread matches above, loose matches on Subject: below --
2019-03-14  7:46 Kangjie Lu
2019-03-14 14:51 ` kbuild test robot
2019-03-19  9:00 ` Dan Carpenter
2019-03-19 13:43 ` Geert Uytterhoeven

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).