]> git.baikalelectronics.ru Git - kernel.git/commit
scsi: bsg: Fix device unregistration
authorZenghui Yu <yuzenghui@huawei.com>
Sat, 11 Sep 2021 10:53:06 +0000 (18:53 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 14 Sep 2021 04:22:15 +0000 (00:22 -0400)
commitf5f32dd0592ce5bdefc710510937c84b6d65be6a
tree6443fd0b512cfb40c33edc2e28dee165409120dc
parent1f35a4aee5104d1a5a4d6d46cfb94dae6c797034
scsi: bsg: Fix device unregistration

device_initialize() is used to take a refcount on the device. However,
put_device() is not called during device teardown. This leads to a
leak of private data of the driver core, dev_name(), etc. This is
reported by kmemleak at boot time if we compile kernel with
DEBUG_TEST_DRIVER_REMOVE.

Fix memory leaks during unregistration and implement a release
function.

Link: https://lore.kernel.org/r/20210911105306.1511-1-yuzenghui@huawei.com
Fixes: 3a06d02c44f0 ("scsi: bsg: Simplify device registration")
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
block/bsg.c