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

uio: uio_cif: 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-1-alexandru.ardelean@analog.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Alexandru Ardelean and committed by
Greg Kroah-Hartman
0a4ade53 c3a74779

+2 -6
+2 -6
drivers/uio/uio_cif.c
··· 43 43 { 44 44 struct uio_info *info; 45 45 46 - info = kzalloc(sizeof(struct uio_info), GFP_KERNEL); 46 + info = devm_kzalloc(&dev->dev, sizeof(struct uio_info), GFP_KERNEL); 47 47 if (!info) 48 48 return -ENOMEM; 49 49 50 50 if (pci_enable_device(dev)) 51 - goto out_free; 51 + return -ENODEV; 52 52 53 53 if (pci_request_regions(dev, "hilscher")) 54 54 goto out_disable; ··· 92 92 pci_release_regions(dev); 93 93 out_disable: 94 94 pci_disable_device(dev); 95 - out_free: 96 - kfree (info); 97 95 return -ENODEV; 98 96 } 99 97 ··· 103 105 pci_release_regions(dev); 104 106 pci_disable_device(dev); 105 107 iounmap(info->mem[0].internal_addr); 106 - 107 - kfree (info); 108 108 } 109 109 110 110 static struct pci_device_id hilscher_pci_ids[] = {