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

uio: uio_netx: use devm_kzalloc() for or 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-3-alexandru.ardelean@analog.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Alexandru Ardelean and committed by
Greg Kroah-Hartman
c3a74779 6b76c98b

+2 -6
+2 -6
drivers/uio/uio_netx.c
··· 53 53 struct uio_info *info; 54 54 int bar; 55 55 56 - info = kzalloc(sizeof(struct uio_info), GFP_KERNEL); 56 + info = devm_kzalloc(&dev->dev, sizeof(struct uio_info), GFP_KERNEL); 57 57 if (!info) 58 58 return -ENOMEM; 59 59 60 60 if (pci_enable_device(dev)) 61 - goto out_free; 61 + return -ENODEV; 62 62 63 63 if (pci_request_regions(dev, "netx")) 64 64 goto out_disable; ··· 112 112 pci_release_regions(dev); 113 113 out_disable: 114 114 pci_disable_device(dev); 115 - out_free: 116 - kfree(info); 117 115 return -ENODEV; 118 116 } 119 117 ··· 125 127 pci_release_regions(dev); 126 128 pci_disable_device(dev); 127 129 iounmap(info->mem[0].internal_addr); 128 - 129 - kfree(info); 130 130 } 131 131 132 132 static struct pci_device_id netx_pci_ids[] = {