diff mbox

PCI: msi: properly free memory on an error path

Message ID 20140123200112.GA15503@kroah.com
State Accepted
Headers show

Commit Message

gregkh@linuxfoundation.org Jan. 23, 2014, 8:01 p.m. UTC
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Coverity reported that I forgot to clean up some allocated memory on the
error path in populate_msi_sysfs(), so this patch fixes that.

Thanks to Dave Jones for pointing out where the error was, I obviously
can't read code this morning...

Fixes: 1c51b50c2995 ("PCI/MSI: Export MSI mode using attributes, not kobjects")
Cc: Dave Jones <davej@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/pci/msi.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Dave Jones Jan. 23, 2014, 8:07 p.m. UTC | #1
On Thu, Jan 23, 2014 at 12:01:12PM -0800, Greg Kroah-Hartman wrote:
 > From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 > 
 > Coverity reported that I forgot to clean up some allocated memory on the
 > error path in populate_msi_sysfs(), so this patch fixes that.
 > 
 > Thanks to Dave Jones for pointing out where the error was, I obviously
 > can't read code this morning...
 
I think it doesn't help that you have 'msi_attr' and 'msi_attrs'.
My eyes kinda glazed over a few times reading those.

	Dave

--
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
Bjorn Helgaas Jan. 29, 2014, 8:56 p.m. UTC | #2
On Thu, Jan 23, 2014 at 12:01:12PM -0800, Greg Kroah-Hartman wrote:
> From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> 
> Coverity reported that I forgot to clean up some allocated memory on the
> error path in populate_msi_sysfs(), so this patch fixes that.
> 
> Thanks to Dave Jones for pointing out where the error was, I obviously
> can't read code this morning...
> 
> Fixes: 1c51b50c2995 ("PCI/MSI: Export MSI mode using attributes, not kobjects")
> Cc: Dave Jones <davej@redhat.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Applied to my pci/msi branch, thanks!

> ---
>  drivers/pci/msi.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
> index 39dff3fe57af..6f0474ebe420 100644
> --- a/drivers/pci/msi.c
> +++ b/drivers/pci/msi.c
> @@ -595,6 +595,7 @@ error_attrs:
>  		++count;
>  		msi_attr = msi_attrs[count];
>  	}
> +	kfree(msi_attrs);
>  	return ret;
>  }
>  
> -- 
> 1.8.5.1.163.gd7aced9
> 
--
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
diff mbox

Patch

diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 39dff3fe57af..6f0474ebe420 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -595,6 +595,7 @@  error_attrs:
 		++count;
 		msi_attr = msi_attrs[count];
 	}
+	kfree(msi_attrs);
 	return ret;
 }