linux/drivers/misc/cxl
Yang Yingliang 61c80d1c38 cxl: fix possible null-ptr-deref in cxl_guest_init_afu|adapter()
If device_register() fails in cxl_register_afu|adapter(), the device
is not added, device_unregister() can not be called in the error path,
otherwise it will cause a null-ptr-deref because of removing not added
device.

As comment of device_register() says, it should use put_device() to give
up the reference in the error path. So split device_unregister() into
device_del() and put_device(), then goes to put dev when register fails.

Fixes: 14baf4d9c7 ("cxl: Add guest-specific code")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Acked-by: Andrew Donnellan <ajd@linux.ibm.com>
Acked-by: Frederic Barrat <fbarrat@linux.ibm.com>
Link: https://lore.kernel.org/r/20221111145440.2426970-1-yangyingliang@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-11-23 20:03:31 +01:00
..
api.c cxl/ocxl: Prepare cleanup of powerpc's asm/prom.h 2022-05-11 23:06:39 +10:00
base.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
context.c cxl: Use the bitmap API to allocate bitmaps 2022-07-14 16:53:52 +02:00
cxl.h cxl: drop unexpected word "the" in the comments 2022-06-27 16:15:38 +02:00
cxllib.c cxl/ocxl: Prepare cleanup of powerpc's asm/prom.h 2022-05-11 23:06:39 +10:00
debugfs.c cxl: no need to check return value of debugfs_create functions 2019-06-18 13:40:25 +02:00
fault.c cxl: remove vma linked list walk 2022-09-26 19:46:20 -07:00
file.c cxl: Fix an error message 2021-05-14 13:43:26 +02:00
flash.c cxl/ocxl: Prepare cleanup of powerpc's asm/prom.h 2022-05-11 23:06:39 +10:00
guest.c cxl: fix possible null-ptr-deref in cxl_guest_init_afu|adapter() 2022-11-23 20:03:31 +01:00
hcalls.c misc: cxl: hcalls: Demote half-assed kerneldoc attempt 2020-07-01 15:08:05 +02:00
hcalls.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
irq.c cxl: Fix a memory leak in an error handling path 2022-07-14 16:53:52 +02:00
Kconfig powerpc/64s: Make hash MMU support configurable 2021-12-09 22:40:24 +11:00
main.c cxl/ocxl: Prepare cleanup of powerpc's asm/prom.h 2022-05-11 23:06:39 +10:00
Makefile Revert "cxl: Allow a default context to be associated with an external pci_dev" 2018-07-02 23:54:33 +10:00
native.c cxl/ocxl: Prepare cleanup of powerpc's asm/prom.h 2022-05-11 23:06:39 +10:00
of.c cxl: Use the bitmap API to allocate bitmaps 2022-07-14 16:53:52 +02:00
pci.c cxl: Use to_pci_driver() instead of pci_dev->driver 2021-10-18 09:20:15 -05:00
sysfs.c cxl: use default_groups in kobj_type 2021-12-29 10:55:50 +01:00
trace.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
trace.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
vphb.c cxl: Change PCIBIOS_SUCCESSFUL to 0 2020-07-13 15:39:52 +02:00