Use devm_kasprintf() instead of simple kasprintf() to free allocated memory
automatically when the device is freed.
Suggested-by: Srikanth Thokala <srikanth.thokala@intel.com>
Link: https://lore.kernel.org/r/20220531132617.20517-1-subramanian.mohan@intel.com
Signed-off-by: Subramanian Mohan <subramanian.mohan@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Nirmal Patel <nirmal.patel@linux.intel.com>
        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;
 
  out_release_instance:
        ida_simple_remove(&vmd_instance_ida, vmd->instance);
-       kfree(vmd->name);
        return err;
 }
 
        vmd_detach_resources(vmd);
        vmd_remove_irq_domain(vmd);
        ida_simple_remove(&vmd_instance_ida, vmd->instance);
-       kfree(vmd->name);
 }
 
 #ifdef CONFIG_PM_SLEEP