voice_svc: Avoid double free in voice_svc driver

voice_svc_dev is allocated as a device managed resource
and need not be freed since it is freed automatically.
Remove the logic to free voice_svc_dev in probe failure
and remove functions to avoid double free.

CRs-Fixed: 2204285
Change-Id: If4f9ca840b00448b987f5ce443f66b0923b01969
Signed-off-by: Aditya Bavanari <abavanar@codeaurora.org>
This commit is contained in:
Aditya Bavanari 2018-04-06 18:15:43 +05:30
parent c2c950b468
commit 2db9527657

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@ -773,7 +773,7 @@ static int voice_svc_probe(struct platform_device *pdev)
if (ret) {
pr_err("%s: Failed to alloc chrdev\n", __func__);
ret = -ENODEV;
goto chrdev_err;
goto done;
}
voice_svc_dev->major = MAJOR(device_num);
@ -820,8 +820,6 @@ dev_err:
class_destroy(voice_svc_class);
class_err:
unregister_chrdev_region(0, MINOR_NUMBER);
chrdev_err:
kfree(voice_svc_dev);
done:
return ret;
}
@ -835,7 +833,6 @@ static int voice_svc_remove(struct platform_device *pdev)
device_destroy(voice_svc_class, device_num);
class_destroy(voice_svc_class);
unregister_chrdev_region(0, MINOR_NUMBER);
kfree(voice_svc_dev);
return 0;
}