https://github.com/torvalds/linux
Revision 1bd3a76880b2bce017987cf53780b372cf59528e authored by Zhu Wang on 19 August 2023, 08:39:41 UTC, committed by Martin K. Petersen on 25 August 2023, 02:30:32 UTC
Commit 41320b18a0e0 ("scsi: snic: Fix possible memory leak if device_add()
fails") fixed the memory leak caused by dev_set_name() when device_add()
failed. However, it did not consider that 'tgt' has already been released
when put_device(&tgt->dev) is called. Remove kfree(tgt) in the error path
to avoid double free of 'tgt' and move put_device(&tgt->dev) after the
removed kfree(tgt) to avoid a use-after-free.

Fixes: 41320b18a0e0 ("scsi: snic: Fix possible memory leak if device_add() fails")
Signed-off-by: Zhu Wang <wangzhu9@huawei.com>
Link: https://lore.kernel.org/r/20230819083941.164365-1-wangzhu9@huawei.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 60c5fd2
History
Tip revision: 1bd3a76880b2bce017987cf53780b372cf59528e authored by Zhu Wang on 19 August 2023, 08:39:41 UTC
scsi: snic: Fix double free in snic_tgt_create()
Tip revision: 1bd3a76
File Mode Size
9p
adfs
affs
afs
autofs
befs
bfs
btrfs
cachefiles
ceph
coda
configfs
cramfs
crypto
debugfs
devpts
dlm
ecryptfs
efivarfs
efs
erofs
exfat
exportfs
ext2
ext4
f2fs
fat
freevxfs
fscache
fuse
gfs2
hfs
hfsplus
hostfs
hpfs
hugetlbfs
iomap
isofs
jbd2
jffs2
jfs
kernfs
lockd
minix
netfs
nfs
nfs_common
nfsd
nilfs2
nls
notify
ntfs
ntfs3
ocfs2
omfs
openpromfs
orangefs
overlayfs
proc
pstore
qnx4
qnx6
quota
ramfs
reiserfs
romfs
smb
squashfs
sysfs
sysv
tracefs
ubifs
udf
ufs
unicode
vboxsf
verity
xfs
zonefs
Kconfig -rw-r--r-- 9.6 KB
Kconfig.binfmt -rw-r--r-- 6.2 KB
Makefile -rw-r--r-- 4.3 KB
aio.c -rw-r--r-- 60.9 KB
anon_inodes.c -rw-r--r-- 8.1 KB
attr.c -rw-r--r-- 14.7 KB
bad_inode.c -rw-r--r-- 5.7 KB
binfmt_elf.c -rw-r--r-- 57.5 KB
binfmt_elf_fdpic.c -rw-r--r-- 43.4 KB
binfmt_elf_test.c -rw-r--r-- 2.7 KB
binfmt_flat.c -rw-r--r-- 25.8 KB
binfmt_misc.c -rw-r--r-- 17.4 KB
binfmt_script.c -rw-r--r-- 4.2 KB
buffer.c -rw-r--r-- 83.2 KB
char_dev.c -rw-r--r-- 16.6 KB
compat_binfmt_elf.c -rw-r--r-- 3.8 KB
coredump.c -rw-r--r-- 29.5 KB
d_path.c -rw-r--r-- 11.4 KB
dax.c -rw-r--r-- 55.6 KB
dcache.c -rw-r--r-- 87.6 KB
direct-io.c -rw-r--r-- 38.4 KB
drop_caches.c -rw-r--r-- 1.9 KB
eventfd.c -rw-r--r-- 11.7 KB
eventpoll.c -rw-r--r-- 66.1 KB
exec.c -rw-r--r-- 51.8 KB
fcntl.c -rw-r--r-- 23.4 KB
fhandle.c -rw-r--r-- 7.2 KB
file.c -rw-r--r-- 32.1 KB
file_table.c -rw-r--r-- 12.4 KB
filesystems.c -rw-r--r-- 6.5 KB
fs-writeback.c -rw-r--r-- 79.8 KB
fs_context.c -rw-r--r-- 17.7 KB
fs_parser.c -rw-r--r-- 10.7 KB
fs_pin.c -rw-r--r-- 1.9 KB
fs_struct.c -rw-r--r-- 3.4 KB
fs_types.c -rw-r--r-- 2.5 KB
fsopen.c -rw-r--r-- 10.9 KB
init.c -rw-r--r-- 6.0 KB
inode.c -rw-r--r-- 68.6 KB
internal.h -rw-r--r-- 8.7 KB
ioctl.c -rw-r--r-- 23.8 KB
kernel_read_file.c -rw-r--r-- 4.4 KB
libfs.c -rw-r--r-- 43.8 KB
locks.c -rw-r--r-- 75.3 KB
mbcache.c -rw-r--r-- 12.6 KB
mnt_idmapping.c -rw-r--r-- 7.7 KB
mount.h -rw-r--r-- 4.0 KB
mpage.c -rw-r--r-- 18.8 KB
namei.c -rw-r--r-- 138.4 KB
namespace.c -rw-r--r-- 123.7 KB
nsfs.c -rw-r--r-- 6.4 KB
open.c -rw-r--r-- 40.0 KB
pipe.c -rw-r--r-- 36.2 KB
pnode.c -rw-r--r-- 16.2 KB
pnode.h -rw-r--r-- 2.1 KB
posix_acl.c -rw-r--r-- 31.3 KB
proc_namespace.c -rw-r--r-- 8.1 KB
read_write.c -rw-r--r-- 40.5 KB
readdir.c -rw-r--r-- 13.8 KB
remap_range.c -rw-r--r-- 14.1 KB
select.c -rw-r--r-- 34.7 KB
seq_file.c -rw-r--r-- 25.7 KB
signalfd.c -rw-r--r-- 8.7 KB
splice.c -rw-r--r-- 44.3 KB
stack.c -rw-r--r-- 2.5 KB
stat.c -rw-r--r-- 22.6 KB
statfs.c -rw-r--r-- 9.7 KB
super.c -rw-r--r-- 46.7 KB
sync.c -rw-r--r-- 10.4 KB
sysctls.c -rw-r--r-- 789 bytes
timerfd.c -rw-r--r-- 13.9 KB
userfaultfd.c -rw-r--r-- 57.2 KB
utimes.c -rw-r--r-- 7.7 KB
xattr.c -rw-r--r-- 35.1 KB

back to top