HID: hyperv: fix possible memory leak in mousevsc_probe()
authorYang Yingliang <yangyingliang@huawei.com>
Fri, 28 Oct 2022 13:40:43 +0000 (21:40 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Nov 2022 08:58:15 +0000 (09:58 +0100)
commit5ad95d71344b7ffec360d62591633b3c465dc049
tree95a0333888e773942eb25c7d1205f25eb0c373da
parent6dcdd1b68b7f9333d48d48fc77b75e7f235f6a4a
HID: hyperv: fix possible memory leak in mousevsc_probe()

[ Upstream commit b5bcb94b0954a026bbd671741fdb00e7141f9c91 ]

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>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/hid/hid-hyperv.c