summaryrefslogtreecommitdiff
path: root/drivers/hid
diff options
context:
space:
mode:
authorAbdun Nihaal <nihaal@cse.iitm.ac.in>2025-11-10 22:45:50 +0530
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-11-24 10:37:40 +0100
commitc0404220cf9e027235dbe562f976548a3f4e31b2 (patch)
treea69a722b17645cce002d47bd2fcb10803528406e /drivers/hid
parent05cb785459f170086b8855b2aa5869f0313c1fb9 (diff)
downloadlinux-c0404220cf9e027235dbe562f976548a3f4e31b2.tar.gz
linux-c0404220cf9e027235dbe562f976548a3f4e31b2.tar.bz2
linux-c0404220cf9e027235dbe562f976548a3f4e31b2.zip
HID: playstation: Fix memory leak in dualshock4_get_calibration_data()
[ Upstream commit 8513c154f8ad7097653dd9bf43d6155e5aad4ab3 ] 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@cse.iitm.ac.in> Reviewed-by: Silvan Jegen <s.jegen@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/hid-playstation.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c
index 1468fb11e39d..657e9ae1be1e 100644
--- a/drivers/hid/hid-playstation.c
+++ b/drivers/hid/hid-playstation.c
@@ -1807,6 +1807,7 @@ static int dualshock4_get_calibration_data(struct dualshock4 *ds4)
hid_warn(hdev, "Failed to retrieve DualShock4 calibration info: %d\n", ret);
ret = -EILSEQ;
+ kfree(buf);
goto transfer_failed;
} else {
break;
@@ -1824,6 +1825,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;
}
}