Re: [PATCH v3] HID: memory leak in dualshock4_get_calibration_data

From: Eslam Khafagy

Date: Tue Nov 25 2025 - 13:19:34 EST



On 11/24/25 16:06, Max Staudt wrote:
On 11/24/25 3:32 PM, Jiri Slaby wrote:
Isn't this fixed already by:
commit 8513c154f8ad7097653dd9bf43d6155e5aad4ab3
Author: Abdun Nihaal <nihaal@xxxxxxxxxxxxxx>
Date:   Mon Nov 10 22:45:50 2025 +0530

     HID: playstation: Fix memory leak in dualshock4_get_calibration_data()
?

As far as I can see, that patch does indeed fix the same issue, and it is already upstream.

Thanks for the hint - Abdun's patch has been upstreamed quite recently, hence I guess Eslam missed it by accident. But maybe I'm wrong and Eslam can chime in himself?
Thank's Max & Jiri,
sorry i was sick the past couple of days i missed your replies.
yes. that patch fixes it. I guess i missed it because it wasn't merged yet when i submitted v1.
So please ignore this patch.


Anyway, this is a typical use-case for __free(). Why not to use that?

Wow, there's been a lot of interesting stuff happening around cleanup.h. I've been out of the kernel for too long, this looks like fun. Thanks for pointing it out :)


Max
Lastly, One question to max,
at the beginning of the function  dualshock4_get_calibration_data
buf = kzalloc(DS4_FEATURE_REPORT_CALIBRATION_SIZE, GFP_KERNEL); if (!buf) { ret = -ENOMEM; goto transfer_failed; }
if the allocation fails. can't we just return here . or do we need to go the the end of the function and do sanity checks at the end?