diff options
author | Arvind Yadav <arvind.yadav.cs@gmail.com> | 2018-03-12 14:36:52 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-03-15 20:12:01 +0300 |
commit | 5fbe9f35dfcd83d94ec9bf4f68a9e0d7cc0550b5 (patch) | |
tree | 113b1cd6de62b6e6ca4703846e16107fa8cb7b32 /drivers/misc | |
parent | 1b723413aada7383a4b24ded93ed26eee1b3a3ca (diff) | |
download | linux-5fbe9f35dfcd83d94ec9bf4f68a9e0d7cc0550b5.tar.xz |
misc: mic: Release reference count and memory for VOP device
Never directly free @dev after calling device_register(),
even if it returned an error! Always use put_device() to
give up the reference initialized.
Release allocated memory for vop device in vop_release_dev().
Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r-- | drivers/misc/mic/bus/vop_bus.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/misc/mic/bus/vop_bus.c b/drivers/misc/mic/bus/vop_bus.c index fd7f2a6049f8..e5bb9c749b5d 100644 --- a/drivers/misc/mic/bus/vop_bus.c +++ b/drivers/misc/mic/bus/vop_bus.c @@ -135,7 +135,9 @@ EXPORT_SYMBOL_GPL(vop_unregister_driver); static void vop_release_dev(struct device *d) { - put_device(d); + struct vop_device *dev = dev_to_vop(d); + + kfree(dev); } struct vop_device * @@ -174,7 +176,7 @@ vop_register_device(struct device *pdev, int id, goto free_vdev; return vdev; free_vdev: - kfree(vdev); + put_device(&vdev->dev); return ERR_PTR(ret); } EXPORT_SYMBOL_GPL(vop_register_device); |