Thread (27 messages) 27 messages, 6 authors, 2018-06-29

[PATCH v4 6/8] PCI: Rework of_pci_get_host_bridge_resources() to devm_of_pci_get_host_bridge_resources()

From: Andy Shevchenko <hidden>
Date: 2018-05-15 16:48:08
Also in: linux-pci, lkml

On Tue, May 15, 2018 at 12:07 PM, Jan Kiszka [off-list ref] wrote:
From: Jan Kiszka <jan.kiszka@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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help