Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI: Use devm_add_action_or_reset()

devm_add_action_or_reset() is a helper function which internally calls
devm_add_action(). If the devm_add_action() fails, it will execute the
action mentioned and return the error code.

Use devm_add_action_or_reset() to reduce source code size (avoid writing
the action twice) and reduce the likelihood of bugs.

Link: https://lore.kernel.org/r/20190708123354.12127-1-huangfq.daxian@gmail.com
Signed-off-by: Fuqian Huang <huangfq.daxian@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

authored by

Fuqian Huang and committed by
Bjorn Helgaas
befa45fb 5f9e832c

+1 -2
+1 -2
drivers/pci/controller/pci-host-common.c
··· 43 43 goto err_out; 44 44 } 45 45 46 - err = devm_add_action(dev, gen_pci_unmap_cfg, cfg); 46 + err = devm_add_action_or_reset(dev, gen_pci_unmap_cfg, cfg); 47 47 if (err) { 48 - gen_pci_unmap_cfg(cfg); 49 48 goto err_out; 50 49 } 51 50 return cfg;