[PATCH] bios: mtrr: free mtrr_list on file open error

IvanHu ivan.hu at canonical.com
Fri May 10 08:47:59 UTC 2013


On 05/07/2013 06:20 AM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> Free mtrr_list on file open error to fix resource leak bug.
>
> Signed-off-by: Colin Ian King <colin.king at 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 at canonical.com>



More information about the fwts-devel mailing list