[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251110171552.95466-1-nihaal@cse.iitm.ac.in>
Date: Mon, 10 Nov 2025 22:45:50 +0530
From: Abdun Nihaal <nihaal@....iitm.ac.in>
To: roderick.colenbrander@...y.com
Cc: Abdun Nihaal <nihaal@....iitm.ac.in>,
jikos@...nel.org,
bentiss@...nel.org,
linux-input@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] HID: playstation: Fix memory leak in dualshock4_get_calibration_data()
The memory allocated for buf is not freed in the error paths when
ps_get_report() fails. Free buf before jumping to transfer_failed label
Fixes: 947992c7fa9e ("HID: playstation: DS4: Fix calibration workaround for clone devices")
Signed-off-by: Abdun Nihaal <nihaal@....iitm.ac.in>
---
Compile tested only. Found using static analysis.
drivers/hid/hid-playstation.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c
index 63f6eb9030d1..128aa6abd10b 100644
--- a/drivers/hid/hid-playstation.c
+++ b/drivers/hid/hid-playstation.c
@@ -1942,6 +1942,7 @@ static int dualshock4_get_calibration_data(struct dualshock4 *ds4)
"Failed to retrieve DualShock4 calibration info: %d\n",
ret);
ret = -EILSEQ;
+ kfree(buf);
goto transfer_failed;
} else {
break;
@@ -1959,6 +1960,7 @@ static int dualshock4_get_calibration_data(struct dualshock4 *ds4)
if (ret) {
hid_warn(hdev, "Failed to retrieve DualShock4 calibration info: %d\n", ret);
+ kfree(buf);
goto transfer_failed;
}
}
--
2.43.0
Powered by blists - more mailing lists