]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
HID: playstation: Fix memory leak in dualshock4_get_calibration_data()
authorAbdun Nihaal <nihaal@cse.iitm.ac.in>
Mon, 10 Nov 2025 17:15:50 +0000 (22:45 +0530)
committerJiri Kosina <jkosina@suse.com>
Tue, 18 Nov 2025 17:07:14 +0000 (18:07 +0100)
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>
drivers/hid/hid-playstation.c

index 63f6eb9030d13cb9d0253022a1f1c195676e34e8..128aa6abd10bed7de96f7ddc324f57d243d0b66b 100644 (file)
@@ -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;
                }
        }