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

uio: uio_mf624: use devm_kzalloc() for uio_info object

This change uses the devm_kzalloc() function to tie the life-time of the
uio_info object to PCI device. This cleans up the exit & error path a bit.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20201120084207.50736-2-alexandru.ardelean@analog.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Alexandru Ardelean and committed by
Greg Kroah-Hartman
6b76c98b 023c9c6d

+2 -6
+2 -6
drivers/uio/uio_mf624.c
··· 136 136 { 137 137 struct uio_info *info; 138 138 139 - info = kzalloc(sizeof(struct uio_info), GFP_KERNEL); 139 + info = devm_kzalloc(&dev->dev, sizeof(struct uio_info), GFP_KERNEL); 140 140 if (!info) 141 141 return -ENOMEM; 142 142 143 143 if (pci_enable_device(dev)) 144 - goto out_free; 144 + return -ENODEV; 145 145 146 146 if (pci_request_regions(dev, "mf624")) 147 147 goto out_disable; ··· 189 189 out_disable: 190 190 pci_disable_device(dev); 191 191 192 - out_free: 193 - kfree(info); 194 192 return -ENODEV; 195 193 } 196 194 ··· 205 207 iounmap(info->mem[0].internal_addr); 206 208 iounmap(info->mem[1].internal_addr); 207 209 iounmap(info->mem[2].internal_addr); 208 - 209 - kfree(info); 210 210 } 211 211 212 212 static const struct pci_device_id mf624_pci_id[] = {