If hid_add_device() returns error, it should call hid_destroy_device() to free the hid which is allocated in hid_allocate_device(). Fixes: 0a6509b0926d ("platform/x86: Add Asus TF103C dock driver") Signed-off-by: Yang Yingliang <yangyingliang@xxxxxxxxxx> --- drivers/platform/x86/asus-tf103c-dock.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/asus-tf103c-dock.c b/drivers/platform/x86/asus-tf103c-dock.c index 62310e06282b..f81d58dfd322 100644 --- a/drivers/platform/x86/asus-tf103c-dock.c +++ b/drivers/platform/x86/asus-tf103c-dock.c @@ -850,8 +850,10 @@ static int tf103c_dock_probe(struct i2c_client *client) strscpy(dock->hid->phys, dev_name(dev), sizeof(dock->hid->phys)); ret = hid_add_device(dock->hid); - if (ret) + if (ret) { + hid_destroy_device(dock->hid); return dev_err_probe(dev, ret, "adding hid dev\n"); + } /* 5. Setup irqchip for touchpad IRQ pass-through */ dock->tp_irqchip.name = KBUILD_MODNAME; -- 2.25.1