habanalabs: put devices before driver removal
[ Upstream commit 5555b7c56b
]
Driver never puts its device and control_device objects, hence
a memory leak is introduced every driver removal.
Signed-off-by: Ofir Bitton <obitton@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
be063ce100
commit
34c07547db
|
@ -229,16 +229,16 @@ delete_cdev_device:
|
||||||
|
|
||||||
static void device_cdev_sysfs_del(struct hl_device *hdev)
|
static void device_cdev_sysfs_del(struct hl_device *hdev)
|
||||||
{
|
{
|
||||||
/* device_release() won't be called so must free devices explicitly */
|
if (!hdev->cdev_sysfs_created)
|
||||||
if (!hdev->cdev_sysfs_created) {
|
goto put_devices;
|
||||||
kfree(hdev->dev_ctrl);
|
|
||||||
kfree(hdev->dev);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
hl_sysfs_fini(hdev);
|
hl_sysfs_fini(hdev);
|
||||||
cdev_device_del(&hdev->cdev_ctrl, hdev->dev_ctrl);
|
cdev_device_del(&hdev->cdev_ctrl, hdev->dev_ctrl);
|
||||||
cdev_device_del(&hdev->cdev, hdev->dev);
|
cdev_device_del(&hdev->cdev, hdev->dev);
|
||||||
|
|
||||||
|
put_devices:
|
||||||
|
put_device(hdev->dev);
|
||||||
|
put_device(hdev->dev_ctrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1285,9 +1285,9 @@ sw_fini:
|
||||||
early_fini:
|
early_fini:
|
||||||
device_early_fini(hdev);
|
device_early_fini(hdev);
|
||||||
free_dev_ctrl:
|
free_dev_ctrl:
|
||||||
kfree(hdev->dev_ctrl);
|
put_device(hdev->dev_ctrl);
|
||||||
free_dev:
|
free_dev:
|
||||||
kfree(hdev->dev);
|
put_device(hdev->dev);
|
||||||
out_disabled:
|
out_disabled:
|
||||||
hdev->disabled = true;
|
hdev->disabled = true;
|
||||||
if (add_cdev_sysfs_on_err)
|
if (add_cdev_sysfs_on_err)
|
||||||
|
|
Loading…
Reference in New Issue