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

uio: uio_aec: use devm_kzalloc() for uio_info object

The uio_info object is free'd last, so it's life-time is tied PCI device
object. Using devm_kzalloc() cleans up the error path a bit and the exit
path.

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

authored by

Alexandru Ardelean and committed by
Greg Kroah-Hartman
16d546c4 0a4ade53

+2 -6
+2 -6
drivers/uio/uio_aec.c
··· 71 71 struct uio_info *info; 72 72 int ret; 73 73 74 - info = kzalloc(sizeof(struct uio_info), GFP_KERNEL); 74 + info = devm_kzalloc(&pdev->dev, sizeof(struct uio_info), GFP_KERNEL); 75 75 if (!info) 76 76 return -ENOMEM; 77 77 78 78 if (pci_enable_device(pdev)) 79 - goto out_free; 79 + return -ENODEV; 80 80 81 81 if (pci_request_regions(pdev, "aectc")) 82 82 goto out_disable; ··· 117 117 pci_release_regions(pdev); 118 118 out_disable: 119 119 pci_disable_device(pdev); 120 - out_free: 121 - kfree(info); 122 120 return -ENODEV; 123 121 } 124 122 ··· 134 136 pci_release_regions(pdev); 135 137 pci_disable_device(pdev); 136 138 iounmap(info->priv); 137 - 138 - kfree(info); 139 139 } 140 140 141 141 static struct pci_driver pci_driver = {