ACK: [PATCH] lib: fwts_cpu: free cpu on error
Alex Hung
alex.hung at canonical.com
Tue May 7 03:30:41 UTC 2013
On 05/07/2013 06:02 AM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> Coverity CID #997346, Resource leak.
>
> Need to free cpu before we return.
>
> Signed-off-by: Colin Ian King <colin.king at 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 at canonical.com>
More information about the fwts-devel
mailing list