Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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@cse.iitm.ac.in>
Reviewed-by: Silvan Jegen <s.jegen@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>

authored by

Abdun Nihaal and committed by
Jiri Kosina
8513c154 9d7b89a1

+2
+2
drivers/hid/hid-playstation.c
··· 1942 1942 "Failed to retrieve DualShock4 calibration info: %d\n", 1943 1943 ret); 1944 1944 ret = -EILSEQ; 1945 + kfree(buf); 1945 1946 goto transfer_failed; 1946 1947 } else { 1947 1948 break; ··· 1960 1959 1961 1960 if (ret) { 1962 1961 hid_warn(hdev, "Failed to retrieve DualShock4 calibration info: %d\n", ret); 1962 + kfree(buf); 1963 1963 goto transfer_failed; 1964 1964 } 1965 1965 }