linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pci: allocation check missing
@ 2014-02-05 11:54 Alan
  2014-02-11 23:28 ` Bjorn Helgaas
  0 siblings, 1 reply; 2+ messages in thread
From: Alan @ 2014-02-05 11:54 UTC (permalink / raw)
  To: linux-pci

If we fail to allocate the name, just drop nicely into the fail path

(as a footnote someone who works on this code more might want to shuffle
 the allocations about so the name and attributes are allocated and freed
 as one. There seems to be no reason to keep them separate)

Signed-off-by: Alan Cox <alan@linux.intel.com>
---
 drivers/pci/msi.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 18ca2497..9bdf290 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -544,9 +544,13 @@ static int populate_msi_sysfs(struct pci_dev *pdev)
 		return -ENOMEM;
 	list_for_each_entry(entry, &pdev->msi_list, list) {
 		char *name = kmalloc(20, GFP_KERNEL);
+		if (!name)
+		        goto error_attrs;
 		msi_dev_attr = kzalloc(sizeof(*msi_dev_attr), GFP_KERNEL);
-		if (!msi_dev_attr)
+		if (!msi_dev_attr) {
+		        kfree(name);
 			goto error_attrs;
+                }
 		sprintf(name, "%d", entry->irq);
 		sysfs_attr_init(&msi_dev_attr->attr);
 		msi_dev_attr->attr.name = name;


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] pci: allocation check missing
  2014-02-05 11:54 [PATCH] pci: allocation check missing Alan
@ 2014-02-11 23:28 ` Bjorn Helgaas
  0 siblings, 0 replies; 2+ messages in thread
From: Bjorn Helgaas @ 2014-02-11 23:28 UTC (permalink / raw)
  To: Alan; +Cc: linux-pci

On Wed, Feb 05, 2014 at 11:54:34AM +0000, Alan wrote:
> If we fail to allocate the name, just drop nicely into the fail path
> 
> (as a footnote someone who works on this code more might want to shuffle
>  the allocations about so the name and attributes are allocated and freed
>  as one. There seems to be no reason to keep them separate)
> 
> Signed-off-by: Alan Cox <alan@linux.intel.com>

I already applied Greg KH's identical patch, thanks! :)

http://git.kernel.org/cgit/linux/kernel/git/helgaas/pci.git/commit/?h=pci/msi&id=b3bac8e57c82e8d3e05f4abcb18c4f0a40656655

> ---
>  drivers/pci/msi.c |    6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
> index 18ca2497..9bdf290 100644
> --- a/drivers/pci/msi.c
> +++ b/drivers/pci/msi.c
> @@ -544,9 +544,13 @@ static int populate_msi_sysfs(struct pci_dev *pdev)
>  		return -ENOMEM;
>  	list_for_each_entry(entry, &pdev->msi_list, list) {
>  		char *name = kmalloc(20, GFP_KERNEL);
> +		if (!name)
> +		        goto error_attrs;
>  		msi_dev_attr = kzalloc(sizeof(*msi_dev_attr), GFP_KERNEL);
> -		if (!msi_dev_attr)
> +		if (!msi_dev_attr) {
> +		        kfree(name);
>  			goto error_attrs;
> +                }
>  		sprintf(name, "%d", entry->irq);
>  		sysfs_attr_init(&msi_dev_attr->attr);
>  		msi_dev_attr->attr.name = name;
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-02-11 23:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-05 11:54 [PATCH] pci: allocation check missing Alan
2014-02-11 23:28 ` Bjorn Helgaas

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).