Commit 8513c154 authored by Abdun Nihaal's avatar Abdun Nihaal Committed by Jiri Kosina
Browse files

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: 947992c7 ("HID: playstation: DS4: Fix calibration workaround for clone devices")
Signed-off-by: default avatarAbdun Nihaal <nihaal@cse.iitm.ac.in>
Reviewed-by: default avatarSilvan Jegen <s.jegen@gmail.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.com>
parent 9d7b89a1
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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;
		}
	}