diff mbox series

lib: fwts_coreboot_cbmem: fix cbmem_console_addr check

Message ID 20180814132221.22709-1-colin.king@canonical.com
State Accepted
Headers show
Series lib: fwts_coreboot_cbmem: fix cbmem_console_addr check | expand

Commit Message

Colin Ian King Aug. 14, 2018, 1:22 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

The check to see if parse_cbmem_ref returned non-zero should
be checking the contents of cbmem_console_addr and not
the pointer cbmem_console_addr. Add the missing *.

Detected by CoverityScan, CID#1394471 ("Dereference before null check")

Fixes: c9bf07f25d13 ("fwts_coreboot.c: add cbmem console parser")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/lib/src/fwts_coreboot_cbmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Alex Hung Aug. 14, 2018, 7:14 p.m. UTC | #1
On 2018-08-14 06:22 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The check to see if parse_cbmem_ref returned non-zero should
> be checking the contents of cbmem_console_addr and not
> the pointer cbmem_console_addr. Add the missing *.
> 
> Detected by CoverityScan, CID#1394471 ("Dereference before null check")
> 
> Fixes: c9bf07f25d13 ("fwts_coreboot.c: add cbmem console parser")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/lib/src/fwts_coreboot_cbmem.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/lib/src/fwts_coreboot_cbmem.c b/src/lib/src/fwts_coreboot_cbmem.c
> index 52f83f47..4185338d 100644
> --- a/src/lib/src/fwts_coreboot_cbmem.c
> +++ b/src/lib/src/fwts_coreboot_cbmem.c
> @@ -152,7 +152,7 @@ static int parse_cbtable_entries(
>   		switch (lbr_p->tag) {
>   		case LB_TAG_CBMEM_CONSOLE: {
>   			*cbmem_console_addr = (off_t)parse_cbmem_ref((struct lb_cbmem_ref *) lbr_p).cbmem_addr;
> -			if (cbmem_console_addr)
> +			if (*cbmem_console_addr)
>   				return 0;
>   			continue;
>   		}
> 

Acked-by: Alex Hung <alex.hung@canonical.com>
Ivan Hu Aug. 16, 2018, 9:07 a.m. UTC | #2
On 08/14/2018 09:22 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The check to see if parse_cbmem_ref returned non-zero should
> be checking the contents of cbmem_console_addr and not
> the pointer cbmem_console_addr. Add the missing *.
>
> Detected by CoverityScan, CID#1394471 ("Dereference before null check")
>
> Fixes: c9bf07f25d13 ("fwts_coreboot.c: add cbmem console parser")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/src/fwts_coreboot_cbmem.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/lib/src/fwts_coreboot_cbmem.c b/src/lib/src/fwts_coreboot_cbmem.c
> index 52f83f47..4185338d 100644
> --- a/src/lib/src/fwts_coreboot_cbmem.c
> +++ b/src/lib/src/fwts_coreboot_cbmem.c
> @@ -152,7 +152,7 @@ static int parse_cbtable_entries(
>  		switch (lbr_p->tag) {
>  		case LB_TAG_CBMEM_CONSOLE: {
>  			*cbmem_console_addr = (off_t)parse_cbmem_ref((struct lb_cbmem_ref *) lbr_p).cbmem_addr;
> -			if (cbmem_console_addr)
> +			if (*cbmem_console_addr)
>  				return 0;
>  			continue;
>  		}

Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff mbox series

Patch

diff --git a/src/lib/src/fwts_coreboot_cbmem.c b/src/lib/src/fwts_coreboot_cbmem.c
index 52f83f47..4185338d 100644
--- a/src/lib/src/fwts_coreboot_cbmem.c
+++ b/src/lib/src/fwts_coreboot_cbmem.c
@@ -152,7 +152,7 @@  static int parse_cbtable_entries(
 		switch (lbr_p->tag) {
 		case LB_TAG_CBMEM_CONSOLE: {
 			*cbmem_console_addr = (off_t)parse_cbmem_ref((struct lb_cbmem_ref *) lbr_p).cbmem_addr;
-			if (cbmem_console_addr)
+			if (*cbmem_console_addr)
 				return 0;
 			continue;
 		}