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

char: xillybus: use devm_add_action_or_reset

If devm_add_action() fails we are explicitly calling dma_unmap_single(),
pci_unmap_single() and kfree(). Lets use the helper
devm_add_action_or_reset() and return directly in case of error, as we
know that the cleanup function has been already called by the helper if
there was any error. At that same time remove the variable rc which
becomes unused now.

Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Sudip Mukherjee and committed by
Greg Kroah-Hartman
bd83a4ab ea37a6b8

+2 -19
+1 -10
drivers/char/xillybus/xillybus_of.c
··· 81 81 { 82 82 dma_addr_t addr; 83 83 struct xilly_mapping *this; 84 - int rc; 85 84 86 85 this = kzalloc(sizeof(*this), GFP_KERNEL); 87 86 if (!this) ··· 100 101 101 102 *ret_dma_handle = addr; 102 103 103 - rc = devm_add_action(ep->dev, xilly_of_unmap, this); 104 - 105 - if (rc) { 106 - dma_unmap_single(ep->dev, addr, size, direction); 107 - kfree(this); 108 - return rc; 109 - } 110 - 111 - return 0; 104 + return devm_add_action_or_reset(ep->dev, xilly_of_unmap, this); 112 105 } 113 106 114 107 static struct xilly_endpoint_hardware of_hw = {
+1 -9
drivers/char/xillybus/xillybus_pcie.c
··· 98 98 int pci_direction; 99 99 dma_addr_t addr; 100 100 struct xilly_mapping *this; 101 - int rc; 102 101 103 102 this = kzalloc(sizeof(*this), GFP_KERNEL); 104 103 if (!this) ··· 119 120 120 121 *ret_dma_handle = addr; 121 122 122 - rc = devm_add_action(ep->dev, xilly_pci_unmap, this); 123 - if (rc) { 124 - pci_unmap_single(ep->pdev, addr, size, pci_direction); 125 - kfree(this); 126 - return rc; 127 - } 128 - 129 - return 0; 123 + return devm_add_action_or_reset(ep->dev, xilly_pci_unmap, this); 130 124 } 131 125 132 126 static struct xilly_endpoint_hardware pci_hw = {