Commit a71464d0 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge tag 'misc-habanalabs-fixes-2020-11-30' of...

Merge tag 'misc-habanalabs-fixes-2020-11-30' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/ogabbay/linux into char-misc-linus

Oded writes:

This tag contains two bug fixes for v5.10-rc7:

- Memory leak every time a user closes the file-descriptor of the device.
  The driver didn't always free all the VA range structures it maintains
  per user.

- Memory leak every time the driver was removed. The device structure was
  not "put" at the device's teardown function in the driver.

* tag 'misc-habanalabs-fixes-2020-11-30' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/ogabbay/linux:
  habanalabs: put devices before driver removal
  habanalabs: free host huge va_range if not used
parents f0992098 5555b7c5
......@@ -231,16 +231,16 @@ static int device_cdev_sysfs_add(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) {
kfree(hdev->dev_ctrl);
kfree(hdev->dev);
return;
}
if (!hdev->cdev_sysfs_created)
goto put_devices;
hl_sysfs_fini(hdev);
cdev_device_del(&hdev->cdev_ctrl, hdev->dev_ctrl);
cdev_device_del(&hdev->cdev, hdev->dev);
put_devices:
put_device(hdev->dev);
put_device(hdev->dev_ctrl);
}
/*
......@@ -1371,9 +1371,9 @@ int hl_device_init(struct hl_device *hdev, struct class *hclass)
early_fini:
device_early_fini(hdev);
free_dev_ctrl:
kfree(hdev->dev_ctrl);
put_device(hdev->dev_ctrl);
free_dev:
kfree(hdev->dev);
put_device(hdev->dev);
out_disabled:
hdev->disabled = true;
if (add_cdev_sysfs_on_err)
......
......@@ -1626,6 +1626,7 @@ static int vm_ctx_init_with_ranges(struct hl_ctx *ctx,
goto host_hpage_range_err;
}
} else {
kfree(ctx->host_huge_va_range);
ctx->host_huge_va_range = ctx->host_va_range;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment