Skip to content

Commit 1266b4a

Browse files
committed
erofs: fix double free of 'copied'
Dan reported a new smatch warning [1] "fs/erofs/inode.c:210 erofs_read_inode() error: double free of 'copied'" Due to new chunk-based format handling logic, the error path can be called after kfree(copied). Set "copied = NULL" after kfree(copied) to fix this. [1] https://lore.kernel.org/r/[email protected] Link: https://lore.kernel.org/r/[email protected] Fixes: c5aa903 ("erofs: support reading chunk-based uncompressed files") Reported-by: kernel test robot <[email protected]> Reported-by: Dan Carpenter <[email protected]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Gao Xiang <[email protected]>
1 parent c5aa903 commit 1266b4a

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

fs/erofs/inode.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ static struct page *erofs_read_inode(struct inode *inode,
127127
/* fill chunked inode summary info */
128128
vi->chunkformat = le16_to_cpu(die->i_u.c.format);
129129
kfree(copied);
130+
copied = NULL;
130131
break;
131132
case EROFS_INODE_LAYOUT_COMPACT:
132133
vi->inode_isize = sizeof(struct erofs_inode_compact);

0 commit comments

Comments
 (0)