diff mbox series

HID: hyperv: fix possible memory leak in mousevsc_probe()

Message ID 20221028134043.1152629-1-yangyingliang@huawei.com
State Accepted
Commit b5bcb94b0954a026bbd671741fdb00e7141f9c91
Headers show
Series HID: hyperv: fix possible memory leak in mousevsc_probe() | expand

Commit Message

Yang Yingliang Oct. 28, 2022, 1:40 p.m. UTC
If hid_add_device() returns error, it should call hid_destroy_device()
to free hid_dev which is allocated in hid_allocate_device().

Fixes: 74c4fb058083 ("HID: hv_mouse: Properly add the hid device")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/hid/hid-hyperv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Wei Liu Nov. 1, 2022, 10:45 a.m. UTC | #1
On Fri, Oct 28, 2022 at 09:40:43PM +0800, Yang Yingliang wrote:
> If hid_add_device() returns error, it should call hid_destroy_device()
> to free hid_dev which is allocated in hid_allocate_device().
> 
> Fixes: 74c4fb058083 ("HID: hv_mouse: Properly add the hid device")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>

Reviewed-by: Wei Liu <wei.liu@kernel.org>
Jiri Kosina Nov. 2, 2022, 1:34 p.m. UTC | #2
On Fri, 28 Oct 2022, Yang Yingliang wrote:

> If hid_add_device() returns error, it should call hid_destroy_device()
> to free hid_dev which is allocated in hid_allocate_device().
> 
> Fixes: 74c4fb058083 ("HID: hv_mouse: Properly add the hid device")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
>  drivers/hid/hid-hyperv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hid/hid-hyperv.c b/drivers/hid/hid-hyperv.c
> index e0bc73124196..ab57b49a44ed 100644
> --- a/drivers/hid/hid-hyperv.c
> +++ b/drivers/hid/hid-hyperv.c
> @@ -499,7 +499,7 @@ static int mousevsc_probe(struct hv_device *device,
>  
>  	ret = hid_add_device(hid_dev);
>  	if (ret)
> -		goto probe_err1;
> +		goto probe_err2;
>  

Good catch, applied, thank you.
diff mbox series

Patch

diff --git a/drivers/hid/hid-hyperv.c b/drivers/hid/hid-hyperv.c
index e0bc73124196..ab57b49a44ed 100644
--- a/drivers/hid/hid-hyperv.c
+++ b/drivers/hid/hid-hyperv.c
@@ -499,7 +499,7 @@  static int mousevsc_probe(struct hv_device *device,
 
 	ret = hid_add_device(hid_dev);
 	if (ret)
-		goto probe_err1;
+		goto probe_err2;
 
 
 	ret = hid_parse(hid_dev);