diff options
| author | Subramanian Mohan <[email protected]> | 2022-05-31 13:26:17 +0000 |
|---|---|---|
| committer | Bjorn Helgaas <[email protected]> | 2022-06-10 14:46:14 +0000 |
| commit | 46d2398c3bc0afaf736c38ccc87cb0e93aa9f29a (patch) | |
| tree | 95be77d6e9ef50ec202415862d21e9716c455ebd /drivers/pci/controller/vmd.c | |
| parent | Linux 5.19-rc1 (diff) | |
| download | kernel-46d2398c3bc0afaf736c38ccc87cb0e93aa9f29a.tar.gz kernel-46d2398c3bc0afaf736c38ccc87cb0e93aa9f29a.zip | |
PCI: vmd: Use devm_kasprintf() instead of simple kasprintf()
Use devm_kasprintf() instead of simple kasprintf() to free allocated memory
automatically when the device is freed.
Suggested-by: Srikanth Thokala <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Subramanian Mohan <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Acked-by: Nirmal Patel <[email protected]>
Diffstat (limited to 'drivers/pci/controller/vmd.c')
| -rw-r--r-- | drivers/pci/controller/vmd.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c index 94a14a3d7e55..cecb55264fb9 100644 --- a/drivers/pci/controller/vmd.c +++ b/drivers/pci/controller/vmd.c @@ -898,7 +898,8 @@ static int vmd_probe(struct pci_dev *dev, const struct pci_device_id *id) if (vmd->instance < 0) return vmd->instance; - vmd->name = kasprintf(GFP_KERNEL, "vmd%d", vmd->instance); + vmd->name = devm_kasprintf(&dev->dev, GFP_KERNEL, "vmd%d", + vmd->instance); if (!vmd->name) { err = -ENOMEM; goto out_release_instance; @@ -936,7 +937,6 @@ static int vmd_probe(struct pci_dev *dev, const struct pci_device_id *id) out_release_instance: ida_simple_remove(&vmd_instance_ida, vmd->instance); - kfree(vmd->name); return err; } @@ -959,7 +959,6 @@ static void vmd_remove(struct pci_dev *dev) vmd_detach_resources(vmd); vmd_remove_irq_domain(vmd); ida_simple_remove(&vmd_instance_ida, vmd->instance); - kfree(vmd->name); } #ifdef CONFIG_PM_SLEEP |
