Skip to content

Commit

Permalink
Merge tag 'misc-habanalabs-fixes-2020-11-30' of ssh://gitolite.kernel…
Browse files Browse the repository at this point in the history
….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
  • Loading branch information
Greg Kroah-Hartman committed Nov 30, 2020
2 parents f099209 + 5555b7c commit a71464d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
16 changes: 8 additions & 8 deletions drivers/misc/habanalabs/common/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/*
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions drivers/misc/habanalabs/common/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit a71464d

Please sign in to comment.