Hi Bjorn, > -----Original Message----- > From: Bjorn Helgaas <helgaas@xxxxxxxxxx> > Sent: Friday, June 10, 2022 8:17 PM > To: Mohan, Subramanian <subramanian.mohan@xxxxxxxxx> > Cc: nirmal.patel@xxxxxxxxxxxxxxx; jonathan.derrick@xxxxxxxxx; > lorenzo.pieralisi@xxxxxxx; robh@xxxxxxxxxx; kw@xxxxxxxxx; > bhelgaas@xxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx; linux- > pci@xxxxxxxxxxxxxxx; Sangannavar, Mallikarjunappa > <mallikarjunappa.sangannavar@xxxxxxxxx>; Thokala, Srikanth > <srikanth.thokala@xxxxxxxxx> > Subject: Re: [PATCH] PCI: vmd: Use devm_kasprintf instead of simple > kasprintf > > On Tue, May 31, 2022 at 06:56:17PM +0530, subramanian.mohan@xxxxxxxxx > wrote: > > From: Subramanian Mohan <subramanian.mohan@xxxxxxxxx> > > > > Use devm_kasprintf instead of simple kasprintf to free the allocated > > memory automatically when the device is freed. > > > > Suggested-by: Srikanth Thokala <srikanth.thokala@xxxxxxxxx> > > Signed-off-by: Subramanian Mohan <subramanian.mohan@xxxxxxxxx> > > Acked-by: Nirmal Patel <nirmal.patel@xxxxxxxxxxxxxxx> > > Applied to pci/ctrl/vmd for v5.20, thanks! Thanks ! > > > --- > > drivers/pci/controller/vmd.c | 5 ++--- > > 1 file changed, 2 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/pci/controller/vmd.c > > b/drivers/pci/controller/vmd.c index eb05cceab964..7a72948e001f 100644 > > --- a/drivers/pci/controller/vmd.c > > +++ b/drivers/pci/controller/vmd.c > > @@ -897,7 +897,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; > > @@ -935,7 +936,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; > > } > > > > @@ -958,7 +958,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 > > -- > > 2.17.1 > >