Message ID | 1431603181-7915-1-git-send-email-colin.king@canonical.com |
---|---|
State | Accepted |
Headers | show |
On 05/14/2015 04:33 AM, Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > CoverityScan picked up a memory leak on the allocated entries that > don't get added to the mttr entry list when they fail specific > filtering criteria. > > Signed-off-by: Colin Ian King <colin.king@canonical.com> > --- > src/bios/mtrr/mtrr.c | 12 +++++++++--- > 1 file changed, 9 insertions(+), 3 deletions(-) > > diff --git a/src/bios/mtrr/mtrr.c b/src/bios/mtrr/mtrr.c > index 8bec28b..c86090f 100644 > --- a/src/bios/mtrr/mtrr.c > +++ b/src/bios/mtrr/mtrr.c > @@ -119,18 +119,24 @@ static int get_mtrrs(void) > */ > > /* Get register, in decimal */ > - if (strncmp(line, "reg", 3)) > + if (strncmp(line, "reg", 3)) { > + free(entry); > continue; > + } > entry->reg = strtoul(line + 3, NULL, 10); > > /* Get base, in hex */ > - if ((ptr1 = strstr(line, "base=0x")) == NULL) > + if ((ptr1 = strstr(line, "base=0x")) == NULL) { > + free(entry); > continue; > + } > entry->start = strtoull(ptr1 + 5, NULL, 16); > > /* Get size, in decimal */ > - if ((ptr1 = strstr(line, "size=")) == NULL) > + if ((ptr1 = strstr(line, "size=")) == NULL) { > + free(entry); > continue; > + } > > entry->size = strtoull(ptr1 + 5, &ptr2, 10); > if (ptr2 && (*ptr2 == 'm')) > Acked-by: Alex Hung <alex.hung@canonical.com>
On 2015年05月14日 19:33, Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > CoverityScan picked up a memory leak on the allocated entries that > don't get added to the mttr entry list when they fail specific > filtering criteria. > > Signed-off-by: Colin Ian King <colin.king@canonical.com> > --- > src/bios/mtrr/mtrr.c | 12 +++++++++--- > 1 file changed, 9 insertions(+), 3 deletions(-) > > diff --git a/src/bios/mtrr/mtrr.c b/src/bios/mtrr/mtrr.c > index 8bec28b..c86090f 100644 > --- a/src/bios/mtrr/mtrr.c > +++ b/src/bios/mtrr/mtrr.c > @@ -119,18 +119,24 @@ static int get_mtrrs(void) > */ > > /* Get register, in decimal */ > - if (strncmp(line, "reg", 3)) > + if (strncmp(line, "reg", 3)) { > + free(entry); > continue; > + } > entry->reg = strtoul(line + 3, NULL, 10); > > /* Get base, in hex */ > - if ((ptr1 = strstr(line, "base=0x")) == NULL) > + if ((ptr1 = strstr(line, "base=0x")) == NULL) { > + free(entry); > continue; > + } > entry->start = strtoull(ptr1 + 5, NULL, 16); > > /* Get size, in decimal */ > - if ((ptr1 = strstr(line, "size=")) == NULL) > + if ((ptr1 = strstr(line, "size=")) == NULL) { > + free(entry); > continue; > + } > > entry->size = strtoull(ptr1 + 5, &ptr2, 10); > if (ptr2 && (*ptr2 == 'm')) Acked-by: Ivan Hu<ivan.hu@canonical.com>
diff --git a/src/bios/mtrr/mtrr.c b/src/bios/mtrr/mtrr.c index 8bec28b..c86090f 100644 --- a/src/bios/mtrr/mtrr.c +++ b/src/bios/mtrr/mtrr.c @@ -119,18 +119,24 @@ static int get_mtrrs(void) */ /* Get register, in decimal */ - if (strncmp(line, "reg", 3)) + if (strncmp(line, "reg", 3)) { + free(entry); continue; + } entry->reg = strtoul(line + 3, NULL, 10); /* Get base, in hex */ - if ((ptr1 = strstr(line, "base=0x")) == NULL) + if ((ptr1 = strstr(line, "base=0x")) == NULL) { + free(entry); continue; + } entry->start = strtoull(ptr1 + 5, NULL, 16); /* Get size, in decimal */ - if ((ptr1 = strstr(line, "size=")) == NULL) + if ((ptr1 = strstr(line, "size=")) == NULL) { + free(entry); continue; + } entry->size = strtoull(ptr1 + 5, &ptr2, 10); if (ptr2 && (*ptr2 == 'm'))