Skip to contentSkip to conversation

hid: hid-playstation: fix memleak in probe

PATCH In review Oliver Neukum 2 participants 2 messages Nov 13, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hid: hid-playstation: fix memleak in probe

Free the buffer if we bail out in the error case of dualshock4_get_calibration_data()

---
 drivers/hid/hid-playstation.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/hid/hid-playstation.c +2 -0
index 63f6eb9030d1..128aa6abd10b 100644
@@ -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;
 		}
 	}
Signature · 1 line
2.51.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Oliver Neukum

Free the buffer if we bail out in the error case of dualshock4_get_calibration_data()

---
 drivers/hid/hid-playstation.c | 2 ++
 1 file changed, 2 insertions(+)

This LGTM!

Quoted 21 lines
drivers/hid/hid-playstation.c +2 -0
index 63f6eb9030d1..128aa6abd10b 100644
@@ -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;
 		}
 	}