[PATCH] bios: mtrr: handle out of memory failures

Keng-Yü Lin kengyu at canonical.com
Mon Mar 5 09:45:07 UTC 2012


On Fri, Mar 2, 2012 at 6:20 PM, Colin King <colin.king at canonical.com> wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
>  src/bios/mtrr/mtrr.c |    9 ++++++++-
>  1 files changed, 8 insertions(+), 1 deletions(-)
>
> diff --git a/src/bios/mtrr/mtrr.c b/src/bios/mtrr/mtrr.c
> index f94a465..4ab742d 100644
> --- a/src/bios/mtrr/mtrr.c
> +++ b/src/bios/mtrr/mtrr.c
> @@ -205,6 +205,11 @@ static fwts_list *get_klog_bios_mtrr(void)
>                                        struct mtrr_entry *mtrr;
>
>                                        mtrr = calloc(1, sizeof(struct mtrr_entry));
> +                                       if (mtrr == NULL) {
> +                                               fwts_list_free(mtrr_bios_list,
> +                                                       free);
> +                                               return NULL;
> +                                       }
>                                        mtrr->type = 0;
>
>                                        uint64_t mask =
> @@ -240,8 +245,10 @@ static int check_vga_controller_address(fwts_framework *fw)
>
>        memset(line,0,4096);
>
> -       if ((mtrr_bios_list = get_klog_bios_mtrr()) == NULL)
> +       if ((mtrr_bios_list = get_klog_bios_mtrr()) == NULL) {
> +               fwts_log_error("Out of memory fetching MTRR list.");
>                return FWTS_ERROR;
> +       }
>
>        snprintf(line, sizeof(line), "%s -v", fw->lspci);
>        fwts_pipe_exec(line, &lspci_output);
> --
> 1.7.9
>
Acked-by: Keng-Yu Lin <kengyu at canonical.com>


More information about the fwts-devel mailing list