Re: [PATCH 2/2] cdx: Fix double free when sysfs file creation fails

From: Gupta, Nipun

Date: Wed Apr 01 2026 - 05:52:34 EST




On 20-03-2026 15:51, Prasanna Kumar T S M wrote:
In cdx_create_res_attr(), if sysfs_create_bin_file() fails, the code
frees res_attr but doesn't set cdx_dev->res_attr[num] to NULL. This
leaves a dangling pointer in the array. Then cdx_destroy_res_attr()
frees the already-freed memory. Fix the double free by initializing
cdx_dev->res_attr[num] after sysfs_create_bin_file() completes.

Fixes: aeda33ab8160 ("cdx: create sysfs bin files for cdx resources")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Prasanna Kumar T S M <ptsm@xxxxxxxxxxxxxxxxxxx>

Acked-by: Nipun Gupta <nipun.gupta@xxxxxxx>