WSL2-Linux-Kernel/drivers
Logan Gunthorpe e654dfd38c nvme: fix memory leak caused by incorrect subsystem free
When freeing the subsystem after finding another match with
__nvme_find_get_subsystem(), use put_device() instead of
__nvme_release_subsystem() which calls kfree() directly.

Per the documentation, put_device() should always be used
after device_initialization() is called. Otherwise, leaks
like the one below which was detected by kmemleak may occur.

Once the call of __nvme_release_subsystem() is removed it no
longer makes sense to keep the helper, so fold it back
into nvme_release_subsystem().

unreferenced object 0xffff8883d12bfbc0 (size 16):
  comm "nvme", pid 2635, jiffies 4294933602 (age 739.952s)
  hex dump (first 16 bytes):
    6e 76 6d 65 2d 73 75 62 73 79 73 32 00 88 ff ff  nvme-subsys2....
  backtrace:
    [<000000007d8fc208>] __kmalloc_track_caller+0x16d/0x2a0
    [<0000000081169e5f>] kvasprintf+0xad/0x130
    [<0000000025626f25>] kvasprintf_const+0x47/0x120
    [<00000000fa66ad36>] kobject_set_name_vargs+0x44/0x120
    [<000000004881f8b3>] dev_set_name+0x98/0xc0
    [<000000007124dae3>] nvme_init_identify+0x1995/0x38e0
    [<000000009315020a>] nvme_loop_configure_admin_queue+0x4fa/0x5e0
    [<000000001a63e766>] nvme_loop_create_ctrl+0x489/0xf80
    [<00000000a46ecc23>] nvmf_dev_write+0x1a12/0x2220
    [<000000002259b3d5>] __vfs_write+0x66/0x120
    [<000000002f6df81e>] vfs_write+0x154/0x490
    [<000000007e8cfc19>] ksys_write+0x10a/0x240
    [<00000000ff5c7b85>] __x64_sys_write+0x73/0xb0
    [<00000000fee6d692>] do_syscall_64+0xaa/0x470
    [<00000000997e1ede>] entry_SYSCALL_64_after_hwframe+0x49/0xbe

Fixes: ab9e00cc72 ("nvme: track subsystems")
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2019-07-23 17:46:43 +02:00
..
accessibility
acpi pci-v5.3-changes 2019-07-15 20:44:49 -07:00
amba Driver Core and debugfs changes for 5.3-rc1 2019-07-12 12:24:03 -07:00
android
ata ata: libahci_platform: remove redundant dev_err message 2019-07-16 08:27:09 -06:00
atm
auxdisplay It's been a relatively busy cycle for docs: 2019-07-09 12:34:26 -07:00
base Driver Core and debugfs changes for 5.3-rc1 2019-07-12 12:24:03 -07:00
bcma
block drbd: dynamically allocate shash descriptor 2019-07-23 07:35:18 -06:00
bluetooth Bluetooth: btusb: Add protocol support for MediaTek MT7663U USB devices 2019-07-06 21:44:25 +02:00
bus
cdrom
char Some small fixes for various things, nothing huge, mostly found 2019-07-13 15:07:02 -07:00
clk - Core Frameworks 2019-07-15 20:18:40 -07:00
clocksource clocksource/drivers/npcm: Fix misuse of GENMASK macro 2019-07-10 11:05:26 +02:00
connector
counter Staging / IIO driver update for 5.3-rc1 2019-07-11 15:36:02 -07:00
cpufreq Merge branch 'pm-cpufreq' 2019-07-08 11:00:02 +02:00
cpuidle
crypto Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2019-07-08 20:57:08 -07:00
dax device-dax: use the dev_pagemap internal refcount 2019-07-02 14:32:44 -03:00
dca
devfreq
dio
dma This pull-request contains the following changes for MTD: 2019-07-13 15:42:44 -07:00
dma-buf drm main pull request for v5.3-rc1 (sans mm changes) 2019-07-15 19:04:27 -07:00
edac
eisa
extcon
firewire
firmware Driver Core and debugfs changes for 5.3-rc1 2019-07-12 12:24:03 -07:00
fpga Driver Core and debugfs changes for 5.3-rc1 2019-07-12 12:24:03 -07:00
fsi
gnss
gpio Merge branch 'i2c/for-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux 2019-07-15 21:10:39 -07:00
gpu pci-v5.3-changes 2019-07-15 20:44:49 -07:00
hid stream_open related bits for Linux 5.3 2019-07-14 17:08:08 -07:00
hsi
hv - Add a module description to the Hyper-V vmbus module. 2019-07-12 15:28:38 -07:00
hwmon Char / Misc driver patches for 5.3-rc1 2019-07-11 15:34:05 -07:00
hwspinlock
hwtracing coresight: Make the coresight_device_fwnode_match declaration's fwnode parameter const 2019-07-12 14:42:05 -07:00
i2c Merge branch 'i2c/for-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux 2019-07-15 21:10:39 -07:00
i3c * Drop support for 10-bit I2C addresses 2019-07-09 09:04:31 -07:00
ide It's been a relatively busy cycle for docs: 2019-07-09 12:34:26 -07:00
idle
iio Driver Core and debugfs changes for 5.3-rc1 2019-07-12 12:24:03 -07:00
infiniband 5.3 Merge window RDMA pull request 2019-07-15 20:38:15 -07:00
input stream_open related bits for Linux 5.3 2019-07-14 17:08:08 -07:00
interconnect
iommu dma-mapping updates for Linux 5.3 2019-07-12 15:13:55 -07:00
ipack TTY / Serial driver updates for 5.3-rc1 2019-07-11 15:38:21 -07:00
irqchip irqchip/gic-v3-its: Fix misuse of GENMASK macro 2019-07-10 11:04:17 +02:00
isdn Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2019-07-11 10:55:49 -07:00
leds LED updates for 5.3-rc1 2019-07-09 08:59:39 -07:00
lightnvm
macintosh powerpc updates for 5.3 2019-07-13 16:08:36 -07:00
mailbox - stm32: race fix by adding a spinlock 2019-07-14 16:36:51 -07:00
mcb
md bcache: fix possible memory leak in bch_cached_dev_run() 2019-07-22 08:15:17 -06:00
media Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2019-07-11 10:55:49 -07:00
memory Char / Misc driver patches for 5.3-rc1 2019-07-11 15:34:05 -07:00
memstick MMC core: 2019-07-11 18:11:21 -07:00
message SCSI misc on 20190709 2019-07-11 15:14:01 -07:00
mfd - Core Frameworks 2019-07-15 20:18:40 -07:00
misc Merge branch 'i2c/for-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux 2019-07-15 21:10:39 -07:00
mmc MMC core: 2019-07-11 18:11:21 -07:00
mtd This pull-request contains the following changes for MTD: 2019-07-13 15:42:44 -07:00
mux
net Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-07-13 15:57:37 -07:00
nfc nfc: st-nci: remove redundant assignment to variable r 2019-07-02 12:00:50 -07:00
ntb
nubus
nvdimm Revert "Merge tag 'keys-acl-20190703' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs" 2019-07-10 18:43:43 -07:00
nvme nvme: fix memory leak caused by incorrect subsystem free 2019-07-23 17:46:43 +02:00
nvmem Driver Core and debugfs changes for 5.3-rc1 2019-07-12 12:24:03 -07:00
of Driver Core and debugfs changes for 5.3-rc1 2019-07-12 12:24:03 -07:00
opp pci-v5.3-changes 2019-07-15 20:44:49 -07:00
oprofile
parisc
parport It's been a relatively busy cycle for docs: 2019-07-09 12:34:26 -07:00
pci pci-v5.3-changes 2019-07-15 20:44:49 -07:00
pcmcia It's been a relatively busy cycle for docs: 2019-07-09 12:34:26 -07:00
perf arm64 updates for 5.3: 2019-07-08 09:54:55 -07:00
phy phy: for 5.3 2019-07-01 15:04:59 +02:00
pinctrl This is the bulk of pin control changes for the v5.3 kernel 2019-07-13 15:02:27 -07:00
platform Merge branch 'i2c/for-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux 2019-07-15 21:10:39 -07:00
pnp
power power supply and reset changes for the v5.3 series 2019-07-15 21:06:15 -07:00
powercap Merge branch 'x86-topology-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2019-07-08 18:28:44 -07:00
pps
ps3
ptp
pwm pwm: Changes for v5.3-rc1 2019-07-09 08:57:45 -07:00
rapidio
ras
regulator - Core Frameworks 2019-07-15 20:18:40 -07:00
remoteproc
reset
rpmsg
rtc - Core Frameworks 2019-07-15 20:18:40 -07:00
s390 s390 updates for the 5.3 merge window #2 2019-07-12 15:39:22 -07:00
sbus
scsi for-linus-20190715 2019-07-15 21:20:52 -07:00
sfi
sh
siox
slimbus
sn
soc pci-v5.3-changes 2019-07-15 20:44:49 -07:00
soundwire soundwire updates for v5.3-rc1 2019-07-05 08:15:08 +02:00
spi Driver Core and debugfs changes for 5.3-rc1 2019-07-12 12:24:03 -07:00
spmi
ssb
staging drm main pull request for v5.3-rc1 (sans mm changes) 2019-07-15 19:04:27 -07:00
target SCSI misc on 20190709 2019-07-11 15:14:01 -07:00
tc
tee
thermal Driver Core and debugfs changes for 5.3-rc1 2019-07-12 12:24:03 -07:00
thunderbolt Driver Core and debugfs changes for 5.3-rc1 2019-07-12 12:24:03 -07:00
tty powerpc updates for 5.3 2019-07-13 16:08:36 -07:00
uio
usb Merge branch 'i2c/for-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux 2019-07-15 21:10:39 -07:00
uwb
vfio
vhost Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2019-07-11 10:55:49 -07:00
video drm main pull request for v5.3-rc1 (sans mm changes) 2019-07-15 19:04:27 -07:00
virt
virtio
visorbus
vlynq
vme
w1
watchdog Driver Core and debugfs changes for 5.3-rc1 2019-07-12 12:24:03 -07:00
xen mm/pgtable: drop pgtable_t variable from pte_fn_t functions 2019-07-12 11:05:46 -07:00
zorro
Kconfig
Makefile