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

From: Gupta, Nipun

Date: Tue Apr 28 2026 - 10:01:25 EST


Hi Prasanna,

On 27-04-2026 12:37, Prasanna Kumar T S M wrote:
Hi Nipun,

On 01-04-2026 15:12, Gupta, Nipun wrote:


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>

I am not able to see this patch in linux-next, although I can see the other patch.

Can you please resend this patch as a separate individual patch so that Greg can pick it up. The other patch i.e. patch 1/2 of this was applied to vfio-next tree as a part of series https://lore.kernel.org/all/20260417202800.88287-1-alex.williamson@xxxxxxxxxx/.

Thanks,
Nipun