Skip to content

Commit 8513c15

Browse files
Abdun NihaalJiri Kosina
authored andcommitted
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: 947992c ("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>
1 parent 9d7b89a commit 8513c15

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

drivers/hid/hid-playstation.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1942,6 +1942,7 @@ static int dualshock4_get_calibration_data(struct dualshock4 *ds4)
19421942
"Failed to retrieve DualShock4 calibration info: %d\n",
19431943
ret);
19441944
ret = -EILSEQ;
1945+
kfree(buf);
19451946
goto transfer_failed;
19461947
} else {
19471948
break;
@@ -1959,6 +1960,7 @@ static int dualshock4_get_calibration_data(struct dualshock4 *ds4)
19591960

19601961
if (ret) {
19611962
hid_warn(hdev, "Failed to retrieve DualShock4 calibration info: %d\n", ret);
1963+
kfree(buf);
19621964
goto transfer_failed;
19631965
}
19641966
}

0 commit comments

Comments
 (0)