Patchwork bios: hdaaudio: free list items and not list

login
register
mail settings
Submitter Colin King
Date May 7, 2013, 7:41 a.m.
Message ID <1367912515-22071-1-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/242057/
State Accepted
Headers show

Comments

Colin King - May 7, 2013, 7:41 a.m.
From: Colin Ian King <colin.king@canonical.com>

Coverity CID #997321: Free of address-of-expression

We should be just free'ing the list items and not the list
descriptor because this is not on the heap.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/bios/hdaaudio/hdaaudio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Alex Hung - May 8, 2013, 2:13 a.m.
On 05/07/2013 03:41 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Coverity CID #997321: Free of address-of-expression
>
> We should be just free'ing the list items and not the list
> descriptor because this is not on the heap.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/bios/hdaaudio/hdaaudio.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/bios/hdaaudio/hdaaudio.c b/src/bios/hdaaudio/hdaaudio.c
> index 47fd60e..ad482b6 100644
> --- a/src/bios/hdaaudio/hdaaudio.c
> +++ b/src/bios/hdaaudio/hdaaudio.c
> @@ -44,7 +44,7 @@ static int hda_audio_read_pins(const char *path, const char *file, fwts_list *se
>   	while (fscanf(fp, "0x%hx 0x%x\n", &pin, &setting) == 2) {
>   		pin_setting = calloc(1, sizeof(hda_audio_pin_setting));
>   		if (pin_setting == NULL) {
> -			fwts_list_free(settings, free);
> +			fwts_list_free_items(settings, free);
>   			fclose(fp);
>   			return FWTS_ERROR;
>   		}
>
Acked-by: Alex Hung <alex.hung@canonical.com>
Keng-Yu Lin - May 20, 2013, 7:30 a.m.
On Tue, May 7, 2013 at 3:41 PM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Coverity CID #997321: Free of address-of-expression
>
> We should be just free'ing the list items and not the list
> descriptor because this is not on the heap.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/bios/hdaaudio/hdaaudio.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/bios/hdaaudio/hdaaudio.c b/src/bios/hdaaudio/hdaaudio.c
> index 47fd60e..ad482b6 100644
> --- a/src/bios/hdaaudio/hdaaudio.c
> +++ b/src/bios/hdaaudio/hdaaudio.c
> @@ -44,7 +44,7 @@ static int hda_audio_read_pins(const char *path, const char *file, fwts_list *se
>         while (fscanf(fp, "0x%hx 0x%x\n", &pin, &setting) == 2) {
>                 pin_setting = calloc(1, sizeof(hda_audio_pin_setting));
>                 if (pin_setting == NULL) {
> -                       fwts_list_free(settings, free);
> +                       fwts_list_free_items(settings, free);
>                         fclose(fp);
>                         return FWTS_ERROR;
>                 }
> --
> 1.8.1.2
>

Acked-by: Keng-Yu Lin <kengyu@canonical.com>

Patch

diff --git a/src/bios/hdaaudio/hdaaudio.c b/src/bios/hdaaudio/hdaaudio.c
index 47fd60e..ad482b6 100644
--- a/src/bios/hdaaudio/hdaaudio.c
+++ b/src/bios/hdaaudio/hdaaudio.c
@@ -44,7 +44,7 @@  static int hda_audio_read_pins(const char *path, const char *file, fwts_list *se
 	while (fscanf(fp, "0x%hx 0x%x\n", &pin, &setting) == 2) {
 		pin_setting = calloc(1, sizeof(hda_audio_pin_setting));
 		if (pin_setting == NULL) {
-			fwts_list_free(settings, free);
+			fwts_list_free_items(settings, free);
 			fclose(fp);
 			return FWTS_ERROR;
 		}