Re: [PATCH] PCI/sysfs: Fix double free in error path

From: Sascha Hauer
Date: Fri Oct 07 2022 - 03:07:46 EST


On Fri, Oct 07, 2022 at 08:56:18AM +0200, Sascha Hauer wrote:
> When pci_create_attr() fails then pci_remove_resource_files() is called
> which will iterate over the res_attr[_wc] arrays and frees every non
> NULL entry. To avoid a double free here we have to set the failed entry
> to NULL in pci_create_attr() when freeing it.
>

You might consider applying this alternative version instead which IMO
looks a bit better.

Sascha

-------------------------------8<-----------------------------