[PATCH v4 6/8] PCI: Rework of_pci_get_host_bridge_resources() to devm_of_pci_get_host_bridge_resources()
Andy Shevchenko
andy.shevchenko at gmail.com
Tue May 15 09:48:05 PDT 2018
On Tue, May 15, 2018 at 12:07 PM, Jan Kiszka <jan.kiszka at siemens.com> wrote:
> From: Jan Kiszka <jan.kiszka at siemens.com>
>
> of_pci_get_host_bridge_resources() allocates the resource structures it
> fills dynamically, but none of its callers care to release them so far.
> Rather than requiring everyone to do this explicitly, convert the
> existing function to a managed version.
> - res = kzalloc(sizeof(struct resource), GFP_KERNEL);
> + res = devm_kzalloc(dev, sizeof(struct resource), GFP_KERNEL);
> if (!res) {
> err = -ENOMEM;
> - goto parse_failed;
> + goto failed;
> }
>
> err = of_pci_range_to_resource(&range, dev_node, res);
> if (err) {
> - kfree(res);
> + devm_kfree(dev, res);
> continue;
> }
Can't you rather make it better, i.e.
struct resource tmp;
...
err = of_pci_range_to_resource(&range, dev_node, &tmp);
if (err)
continue;
res = devm_kmemdump();
if (!res) {
ret = -ENOMEM;
goto failed;
}
?
--
With Best Regards,
Andy Shevchenko
More information about the linux-arm-kernel
mailing list