| Submitter | Colin King |
|---|---|
| Date | March 2, 2012, 10:20 a.m. |
| Message ID | <1330683637-19676-1-git-send-email-colin.king@canonical.com> |
| Download | mbox | patch |
| Permalink | /patch/144196/ |
| State | Accepted |
| Headers | show |
Comments
On Fri, Mar 2, 2012 at 6:20 PM, Colin King <colin.king@canonical.com> wrote: > From: Colin Ian King <colin.king@canonical.com> > > Signed-off-by: Colin Ian King <colin.king@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@canonical.com>
On 03/02/2012 06:20 PM, Colin King wrote: > From: Colin Ian King<colin.king@canonical.com> > > Signed-off-by: Colin Ian King<colin.king@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); Acked-by: Alex Hung<alex.hung@canonical.com>
Patch
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);