Skip to content

Commit a9cfcd6

Browse files
committed
ext4: avoid trying to kfree an ERR_PTR pointer
Thanks to Dan Carpenter for extending smatch to find bugs like this. (This was found using a development version of smatch.) Fixes: 36de928 Reported-by: Dan Carpenter <dan.carpenter@oracle.com Signed-off-by: Theodore Ts'o <tytso@mit.edu> Cc: stable@vger.kernel.org
1 parent d4f0318 commit a9cfcd6

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

‎fs/ext4/namei.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3240,6 +3240,7 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
32403240
&new.de, &new.inlined);
32413241
if (IS_ERR(new.bh)) {
32423242
retval = PTR_ERR(new.bh);
3243+
new.bh = NULL;
32433244
goto end_rename;
32443245
}
32453246
if (new.bh) {
@@ -3386,6 +3387,7 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
33863387
&new.de, &new.inlined);
33873388
if (IS_ERR(new.bh)) {
33883389
retval = PTR_ERR(new.bh);
3390+
new.bh = NULL;
33893391
goto end_rename;
33903392
}
33913393

‎fs/ext4/resize.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,7 @@ static int setup_new_flex_group_blocks(struct super_block *sb,
575575
bh = bclean(handle, sb, block);
576576
if (IS_ERR(bh)) {
577577
err = PTR_ERR(bh);
578+
bh = NULL;
578579
goto out;
579580
}
580581
overhead = ext4_group_overhead_blocks(sb, group);
@@ -603,6 +604,7 @@ static int setup_new_flex_group_blocks(struct super_block *sb,
603604
bh = bclean(handle, sb, block);
604605
if (IS_ERR(bh)) {
605606
err = PTR_ERR(bh);
607+
bh = NULL;
606608
goto out;
607609
}
608610

0 commit comments

Comments
 (0)