1
0
Fork 0
alistair23-linux/drivers/staging/gasket
Xiyu Yang 3468bca1ea staging: gasket: Fix mapping refcnt leak when register/store fails
[ Upstream commit e3436ce60c ]

gasket_sysfs_register_store() invokes get_mapping(), which returns a
reference of the specified gasket_sysfs_mapping object to "mapping" with
increased refcnt.

When gasket_sysfs_register_store() returns, local variable "mapping"
becomes invalid, so the refcount should be decreased to keep refcount
balanced.

The reference counting issue happens in one exception handling path of
gasket_sysfs_register_store(). When gasket_dev is NULL, the function
forgets to decrease the refcnt increased by get_mapping(), causing a
refcnt leak.

Fix this issue by calling put_mapping() when gasket_dev is NULL.

Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Link: https://lore.kernel.org/r/1587618941-13718-1-git-send-email-xiyuyang19@fudan.edu.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-06-24 17:50:21 +02:00
..
Kconfig staging: add missing SPDX lines to Kconfig files 2019-04-03 11:10:15 +02:00
Makefile staging: add missing SPDX lines to Makefile files 2019-04-03 11:10:15 +02:00
TODO staging: gasket: TODO: re-implement using UIO 2018-09-10 18:08:06 +02:00
apex.h staging: gasket: apex: move driver-private defines out of apex.h 2018-08-01 20:07:03 +02:00
apex_driver.c PCI: Move Apex Edge TPU class quirk to fix BAR assignment 2020-05-02 08:48:50 +02:00
gasket.h staging: gasket: remove "reset type" param from framework 2018-08-02 11:00:21 +02:00
gasket_constants.h staging: gasket: remove "reset type" param from framework 2018-08-02 11:00:21 +02:00
gasket_core.c staging: gasket: Check the return value of gasket_get_bar_index() 2020-05-14 07:58:27 +02:00
gasket_core.h staging: gasket: Fix sparse "incorrect type in assignment" warnings. 2018-10-19 21:12:29 +02:00
gasket_interrupt.c staging: gasket: gasket_interuppt.c: Fix string split issue. 2019-03-18 07:49:45 +01:00
gasket_interrupt.h staging: gasket: interrupt: simplify interrupt init parameters 2018-08-27 19:43:44 +02:00
gasket_ioctl.c staging: gasket: Remove unnecessary line-breaks in function signatures 2019-08-18 08:51:11 +02:00
gasket_ioctl.h staging: gasket: common ioctl dispatcher add __user annotations 2018-07-21 08:50:36 +02:00
gasket_page_table.c staging/gasket: Fix string split 2019-05-30 14:09:47 -07:00
gasket_page_table.h staging: gasket: page table: fix header file include guard symbol 2018-08-01 20:07:03 +02:00
gasket_sysfs.c staging: gasket: Fix mapping refcnt leak when register/store fails 2020-06-24 17:50:21 +02:00
gasket_sysfs.h staging: gasket: Fix incongruency in handling of sysfs entries creation 2020-04-29 16:33:14 +02:00