Message ID | 1367877749-17828-1-git-send-email-colin.king@canonical.com |
---|---|
State | Accepted |
Headers | show |
On 05/07/2013 06:02 AM, Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > Coverity CID #997346, Resource leak. > > Need to free cpu before we return. > > Signed-off-by: Colin Ian King <colin.king@canonical.com> > --- > src/lib/src/fwts_cpu.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/src/lib/src/fwts_cpu.c b/src/lib/src/fwts_cpu.c > index d6c11ba..282bc42 100644 > --- a/src/lib/src/fwts_cpu.c > +++ b/src/lib/src/fwts_cpu.c > @@ -114,8 +114,10 @@ fwts_cpuinfo_x86 *fwts_cpu_get_info(const int which_cpu) > if ((cpu = (fwts_cpuinfo_x86*)calloc(1, sizeof(fwts_cpuinfo_x86))) == NULL) > return NULL; > > - if ((fp = fopen("/proc/cpuinfo", "r")) == NULL) > + if ((fp = fopen("/proc/cpuinfo", "r")) == NULL) { > + free(cpu); > return NULL; > + } > > while (fgets(buffer, sizeof(buffer), fp) != NULL) { > char *ptr = strstr(buffer, ":"); > Acked-by: Alex Hung <alex.hung@canonical.com>
On 05/07/2013 06:02 AM, Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > Coverity CID #997346, Resource leak. > > Need to free cpu before we return. > > Signed-off-by: Colin Ian King <colin.king@canonical.com> > --- > src/lib/src/fwts_cpu.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/src/lib/src/fwts_cpu.c b/src/lib/src/fwts_cpu.c > index d6c11ba..282bc42 100644 > --- a/src/lib/src/fwts_cpu.c > +++ b/src/lib/src/fwts_cpu.c > @@ -114,8 +114,10 @@ fwts_cpuinfo_x86 *fwts_cpu_get_info(const int which_cpu) > if ((cpu = (fwts_cpuinfo_x86*)calloc(1, sizeof(fwts_cpuinfo_x86))) == NULL) > return NULL; > > - if ((fp = fopen("/proc/cpuinfo", "r")) == NULL) > + if ((fp = fopen("/proc/cpuinfo", "r")) == NULL) { > + free(cpu); > return NULL; > + } > > while (fgets(buffer, sizeof(buffer), fp) != NULL) { > char *ptr = strstr(buffer, ":"); > Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff --git a/src/lib/src/fwts_cpu.c b/src/lib/src/fwts_cpu.c index d6c11ba..282bc42 100644 --- a/src/lib/src/fwts_cpu.c +++ b/src/lib/src/fwts_cpu.c @@ -114,8 +114,10 @@ fwts_cpuinfo_x86 *fwts_cpu_get_info(const int which_cpu) if ((cpu = (fwts_cpuinfo_x86*)calloc(1, sizeof(fwts_cpuinfo_x86))) == NULL) return NULL; - if ((fp = fopen("/proc/cpuinfo", "r")) == NULL) + if ((fp = fopen("/proc/cpuinfo", "r")) == NULL) { + free(cpu); return NULL; + } while (fgets(buffer, sizeof(buffer), fp) != NULL) { char *ptr = strstr(buffer, ":");