Skip to content

Commit 0eeaa2b

Browse files
Ma Kegregkh
authored andcommitted
perf: arm_cspmu: fix error handling in arm_cspmu_impl_unregister()
commit 970e1e4 upstream. driver_find_device() calls get_device() to increment the reference count once a matching device is found. device_release_driver() releases the driver, but it does not decrease the reference count that was incremented by driver_find_device(). At the end of the loop, there is no put_device() to balance the reference count. To avoid reference count leakage, add put_device() to decrease the reference count. Found by code review. Cc: stable@vger.kernel.org Fixes: bfc653a ("perf: arm_cspmu: Separate Arm and vendor module") Signed-off-by: Ma Ke <make24@iscas.ac.cn> Signed-off-by: Will Deacon <will@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent bacecf3 commit 0eeaa2b

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/perf/arm_cspmu/arm_cspmu.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1365,8 +1365,10 @@ void arm_cspmu_impl_unregister(const struct arm_cspmu_impl_match *impl_match)
13651365

13661366
/* Unbind the driver from all matching backend devices. */
13671367
while ((dev = driver_find_device(&arm_cspmu_driver.driver, NULL,
1368-
match, arm_cspmu_match_device)))
1368+
match, arm_cspmu_match_device))) {
13691369
device_release_driver(dev);
1370+
put_device(dev);
1371+
}
13701372

13711373
mutex_lock(&arm_cspmu_lock);
13721374

0 commit comments

Comments
 (0)