* [PATCH] PCI: vmd: Use devm_kasprintf instead of simple kasprintf @ 2022-05-31 13:26 subramanian.mohan 2022-05-31 18:39 ` Bjorn Helgaas 2022-06-10 14:47 ` Bjorn Helgaas 0 siblings, 2 replies; 6+ messages in thread From: subramanian.mohan @ 2022-05-31 13:26 UTC (permalink / raw) To: nirmal.patel, jonathan.derrick, lorenzo.pieralisi, robh, kw, bhelgaas Cc: linux-kernel, linux-pci, mallikarjunappa.sangannavar, srikanth.thokala From: Subramanian Mohan <subramanian.mohan@intel.com> Use devm_kasprintf instead of simple kasprintf to free the allocated memory automatically when the device is freed. Suggested-by: Srikanth Thokala <srikanth.thokala@intel.com> Signed-off-by: Subramanian Mohan <subramanian.mohan@intel.com> Acked-by: Nirmal Patel <nirmal.patel@linux.intel.com> --- 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 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] PCI: vmd: Use devm_kasprintf instead of simple kasprintf 2022-05-31 13:26 [PATCH] PCI: vmd: Use devm_kasprintf instead of simple kasprintf subramanian.mohan @ 2022-05-31 18:39 ` Bjorn Helgaas 2022-06-01 11:14 ` Mohan, Subramanian 2022-06-10 14:47 ` Bjorn Helgaas 1 sibling, 1 reply; 6+ messages in thread From: Bjorn Helgaas @ 2022-05-31 18:39 UTC (permalink / raw) To: subramanian.mohan Cc: nirmal.patel, jonathan.derrick, lorenzo.pieralisi, robh, kw, bhelgaas, linux-kernel, linux-pci, mallikarjunappa.sangannavar, srikanth.thokala On Tue, May 31, 2022 at 06:56:17PM +0530, subramanian.mohan@intel.com wrote: > From: Subramanian Mohan <subramanian.mohan@intel.com> > > Use devm_kasprintf instead of simple kasprintf to free the allocated memory > automatically when the device is freed. I guess this is pure simplification, not a bug fix, since we *did* free the buffer in the error path and in vmd_remove(), right? > Suggested-by: Srikanth Thokala <srikanth.thokala@intel.com> > Signed-off-by: Subramanian Mohan <subramanian.mohan@intel.com> > Acked-by: Nirmal Patel <nirmal.patel@linux.intel.com> > --- > 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 > ^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH] PCI: vmd: Use devm_kasprintf instead of simple kasprintf 2022-05-31 18:39 ` Bjorn Helgaas @ 2022-06-01 11:14 ` Mohan, Subramanian 2022-06-10 6:57 ` Mohan, Subramanian 0 siblings, 1 reply; 6+ messages in thread From: Mohan, Subramanian @ 2022-06-01 11:14 UTC (permalink / raw) To: Bjorn Helgaas Cc: nirmal.patel, jonathan.derrick, lorenzo.pieralisi, robh, kw, bhelgaas, linux-kernel, linux-pci, Sangannavar, Mallikarjunappa, Thokala, Srikanth > -----Original Message----- > From: Bjorn Helgaas <helgaas@kernel.org> > Sent: Wednesday, June 1, 2022 12:09 AM > To: Mohan, Subramanian <subramanian.mohan@intel.com> > Cc: nirmal.patel@linux.intel.com; jonathan.derrick@linux.dev; > lorenzo.pieralisi@arm.com; robh@kernel.org; kw@linux.com; > bhelgaas@google.com; linux-kernel@vger.kernel.org; linux- > pci@vger.kernel.org; Sangannavar, Mallikarjunappa > <mallikarjunappa.sangannavar@intel.com>; Thokala, Srikanth > <srikanth.thokala@intel.com> > Subject: Re: [PATCH] PCI: vmd: Use devm_kasprintf instead of simple > kasprintf > > On Tue, May 31, 2022 at 06:56:17PM +0530, subramanian.mohan@intel.com > wrote: > > From: Subramanian Mohan <subramanian.mohan@intel.com> > > > > Use devm_kasprintf instead of simple kasprintf to free the allocated > > memory automatically when the device is freed. > > I guess this is pure simplification, not a bug fix, since we *did* free the buffer > in the error path and in vmd_remove(), right? > Yes this is simplification and not bug fix. Thanks, Subbu > > Suggested-by: Srikanth Thokala <srikanth.thokala@intel.com> > > Signed-off-by: Subramanian Mohan <subramanian.mohan@intel.com> > > Acked-by: Nirmal Patel <nirmal.patel@linux.intel.com> > > --- > > 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 > > ^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH] PCI: vmd: Use devm_kasprintf instead of simple kasprintf 2022-06-01 11:14 ` Mohan, Subramanian @ 2022-06-10 6:57 ` Mohan, Subramanian 0 siblings, 0 replies; 6+ messages in thread From: Mohan, Subramanian @ 2022-06-10 6:57 UTC (permalink / raw) To: Bjorn Helgaas Cc: nirmal.patel, jonathan.derrick, lorenzo.pieralisi, robh, kw, bhelgaas, linux-kernel, linux-pci, Sangannavar, Mallikarjunappa, Thokala, Srikanth Hi Bjorn, > -----Original Message----- > From: Mohan, Subramanian > Sent: Wednesday, June 1, 2022 4:45 PM > To: Bjorn Helgaas <helgaas@kernel.org> > Cc: nirmal.patel@linux.intel.com; jonathan.derrick@linux.dev; > lorenzo.pieralisi@arm.com; robh@kernel.org; kw@linux.com; > bhelgaas@google.com; linux-kernel@vger.kernel.org; linux- > pci@vger.kernel.org; Sangannavar, Mallikarjunappa > <mallikarjunappa.sangannavar@intel.com>; Thokala, Srikanth > <Srikanth.Thokala@intel.com> > Subject: RE: [PATCH] PCI: vmd: Use devm_kasprintf instead of simple kasprintf > > > > > -----Original Message----- > > From: Bjorn Helgaas <helgaas@kernel.org> > > Sent: Wednesday, June 1, 2022 12:09 AM > > To: Mohan, Subramanian <subramanian.mohan@intel.com> > > Cc: nirmal.patel@linux.intel.com; jonathan.derrick@linux.dev; > > lorenzo.pieralisi@arm.com; robh@kernel.org; kw@linux.com; > > bhelgaas@google.com; linux-kernel@vger.kernel.org; linux- > > pci@vger.kernel.org; Sangannavar, Mallikarjunappa > > <mallikarjunappa.sangannavar@intel.com>; Thokala, Srikanth > > <srikanth.thokala@intel.com> > > Subject: Re: [PATCH] PCI: vmd: Use devm_kasprintf instead of simple > > kasprintf > > > > On Tue, May 31, 2022 at 06:56:17PM +0530, subramanian.mohan@intel.com > > wrote: > > > From: Subramanian Mohan <subramanian.mohan@intel.com> > > > > > > Use devm_kasprintf instead of simple kasprintf to free the allocated > > > memory automatically when the device is freed. > > > > I guess this is pure simplification, not a bug fix, since we *did* > > free the buffer in the error path and in vmd_remove(), right? > > > > Yes this is simplification and not bug fix. Gentle reminder, kindly let me know any further comments. > > Thanks, > Subbu > > > > Suggested-by: Srikanth Thokala <srikanth.thokala@intel.com> > > > Signed-off-by: Subramanian Mohan <subramanian.mohan@intel.com> > > > Acked-by: Nirmal Patel <nirmal.patel@linux.intel.com> > > > --- > > > 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 > > > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] PCI: vmd: Use devm_kasprintf instead of simple kasprintf 2022-05-31 13:26 [PATCH] PCI: vmd: Use devm_kasprintf instead of simple kasprintf subramanian.mohan 2022-05-31 18:39 ` Bjorn Helgaas @ 2022-06-10 14:47 ` Bjorn Helgaas 2022-06-13 6:33 ` Mohan, Subramanian 1 sibling, 1 reply; 6+ messages in thread From: Bjorn Helgaas @ 2022-06-10 14:47 UTC (permalink / raw) To: subramanian.mohan Cc: nirmal.patel, jonathan.derrick, lorenzo.pieralisi, robh, kw, bhelgaas, linux-kernel, linux-pci, mallikarjunappa.sangannavar, srikanth.thokala On Tue, May 31, 2022 at 06:56:17PM +0530, subramanian.mohan@intel.com wrote: > From: Subramanian Mohan <subramanian.mohan@intel.com> > > Use devm_kasprintf instead of simple kasprintf to free the allocated memory > automatically when the device is freed. > > Suggested-by: Srikanth Thokala <srikanth.thokala@intel.com> > Signed-off-by: Subramanian Mohan <subramanian.mohan@intel.com> > Acked-by: Nirmal Patel <nirmal.patel@linux.intel.com> Applied to pci/ctrl/vmd for v5.20, 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 > ^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH] PCI: vmd: Use devm_kasprintf instead of simple kasprintf 2022-06-10 14:47 ` Bjorn Helgaas @ 2022-06-13 6:33 ` Mohan, Subramanian 0 siblings, 0 replies; 6+ messages in thread From: Mohan, Subramanian @ 2022-06-13 6:33 UTC (permalink / raw) To: Bjorn Helgaas Cc: nirmal.patel, jonathan.derrick, lorenzo.pieralisi, robh, kw, bhelgaas, linux-kernel, linux-pci, Sangannavar, Mallikarjunappa, Thokala, Srikanth Hi Bjorn, > -----Original Message----- > From: Bjorn Helgaas <helgaas@kernel.org> > Sent: Friday, June 10, 2022 8:17 PM > To: Mohan, Subramanian <subramanian.mohan@intel.com> > Cc: nirmal.patel@linux.intel.com; jonathan.derrick@linux.dev; > lorenzo.pieralisi@arm.com; robh@kernel.org; kw@linux.com; > bhelgaas@google.com; linux-kernel@vger.kernel.org; linux- > pci@vger.kernel.org; Sangannavar, Mallikarjunappa > <mallikarjunappa.sangannavar@intel.com>; Thokala, Srikanth > <srikanth.thokala@intel.com> > Subject: Re: [PATCH] PCI: vmd: Use devm_kasprintf instead of simple > kasprintf > > On Tue, May 31, 2022 at 06:56:17PM +0530, subramanian.mohan@intel.com > wrote: > > From: Subramanian Mohan <subramanian.mohan@intel.com> > > > > Use devm_kasprintf instead of simple kasprintf to free the allocated > > memory automatically when the device is freed. > > > > Suggested-by: Srikanth Thokala <srikanth.thokala@intel.com> > > Signed-off-by: Subramanian Mohan <subramanian.mohan@intel.com> > > Acked-by: Nirmal Patel <nirmal.patel@linux.intel.com> > > 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 > > ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-06-13 6:33 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-05-31 13:26 [PATCH] PCI: vmd: Use devm_kasprintf instead of simple kasprintf subramanian.mohan 2022-05-31 18:39 ` Bjorn Helgaas 2022-06-01 11:14 ` Mohan, Subramanian 2022-06-10 6:57 ` Mohan, Subramanian 2022-06-10 14:47 ` Bjorn Helgaas 2022-06-13 6:33 ` Mohan, Subramanian
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).