erofs: fix double free of 'copied'
authorGao Xiang <hsiangkao@linux.alibaba.com>
Wed, 25 Aug 2021 12:07:57 +0000 (20:07 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Wed, 25 Aug 2021 14:05:58 +0000 (22:05 +0800)
commit1266b4a7ecb679587dc4d098abe56ea53313d569
treed6583315427965eae54a2725916e083694748ab5
parentc5aa903a59db274554718cddfda9039913409ec9
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/202108251030.bELQozR7-lkp@intel.com

Link: https://lore.kernel.org/r/20210825120757.11034-1-hsiangkao@linux.alibaba.com
Fixes: c5aa903a59db ("erofs: support reading chunk-based uncompressed files")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
fs/erofs/inode.c