Re: [PATCH] platform/x86: asus-tf103c-dock: fix possible memory leak in tf103c_dock_probe()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On 2022/11/7 22:28, Hans de Goede wrote:
Hi Yang,

On 10/29/22 08:27, Yang Yingliang wrote:
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");
+	}
hid_destroy_device() is already called by tf103c_dock_non_devm_cleanup()
which is registered early on as a cleanup handler through
devm_add_action_or_reset().
Thanks for correcting me.

Yang

Regards,

Hans


.



[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux