diff mbox

bios: mtrr: free mtrr_list on file open error

Message ID 1367878804-18734-1-git-send-email-colin.king@canonical.com
State Accepted
Headers show

Commit Message

Colin Ian King May 6, 2013, 10:20 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

Free mtrr_list on file open error to fix resource leak bug.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/bios/mtrr/mtrr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Alex Hung May 7, 2013, 3:43 a.m. UTC | #1
On 05/07/2013 06:20 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Free mtrr_list on file open error to fix resource leak bug.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/bios/mtrr/mtrr.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/src/bios/mtrr/mtrr.c b/src/bios/mtrr/mtrr.c
> index 284d153..38f89fb 100644
> --- a/src/bios/mtrr/mtrr.c
> +++ b/src/bios/mtrr/mtrr.c
> @@ -88,8 +88,10 @@ static int get_mtrrs(void)
>   	if ((mtrr_list = fwts_list_new()) == NULL)
>   		return FWTS_ERROR;
>
> -	if ((fp = fopen("/proc/mtrr", "r")) == NULL)
> +	if ((fp = fopen("/proc/mtrr", "r")) == NULL) {
> +		fwts_list_free(mtrr_list, free);
>   		return FWTS_ERROR;
> +	}
>
>   	while (!feof(fp)) {
>   		char *ptr1, *ptr2;
>
Acked-by: Alex Hung <alex.hung@canonical.com>
Ivan Hu May 10, 2013, 8:47 a.m. UTC | #2
On 05/07/2013 06:20 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Free mtrr_list on file open error to fix resource leak bug.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/bios/mtrr/mtrr.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/src/bios/mtrr/mtrr.c b/src/bios/mtrr/mtrr.c
> index 284d153..38f89fb 100644
> --- a/src/bios/mtrr/mtrr.c
> +++ b/src/bios/mtrr/mtrr.c
> @@ -88,8 +88,10 @@ static int get_mtrrs(void)
>   	if ((mtrr_list = fwts_list_new()) == NULL)
>   		return FWTS_ERROR;
>
> -	if ((fp = fopen("/proc/mtrr", "r")) == NULL)
> +	if ((fp = fopen("/proc/mtrr", "r")) == NULL) {
> +		fwts_list_free(mtrr_list, free);
>   		return FWTS_ERROR;
> +	}
>
>   	while (!feof(fp)) {
>   		char *ptr1, *ptr2;
>

Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff mbox

Patch

diff --git a/src/bios/mtrr/mtrr.c b/src/bios/mtrr/mtrr.c
index 284d153..38f89fb 100644
--- a/src/bios/mtrr/mtrr.c
+++ b/src/bios/mtrr/mtrr.c
@@ -88,8 +88,10 @@  static int get_mtrrs(void)
 	if ((mtrr_list = fwts_list_new()) == NULL)
 		return FWTS_ERROR;
 
-	if ((fp = fopen("/proc/mtrr", "r")) == NULL)
+	if ((fp = fopen("/proc/mtrr", "r")) == NULL) {
+		fwts_list_free(mtrr_list, free);
 		return FWTS_ERROR;
+	}
 
 	while (!feof(fp)) {
 		char *ptr1, *ptr2;