Re: [PATCH v2] scsi: bsg: Fix device unregistration

From: John Garry
Date: Tue Sep 14 2021 - 05:49:31 EST


On 11/09/2021 11:53, Zenghui Yu wrote:
We use device_initialize() to take refcount for the device but forget to
put_device() on device teardown, which ends up leaking 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.

Note that adding the missing put_device() is_not_ sufficient to fix device
unregistration. As we don't provide the .release() method for device, which
turned out to be typically wrong and will be complained loudly by the
driver core.

Fix both of them.

Fixes: ead09dd3aed5 ("scsi: bsg: Simplify device registration")
Signed-off-by: Zenghui Yu<yuzenghui@xxxxxxxxxx>


FWIW,

Tested-by: John Garry <john.garry@xxxxxxxxxx>