diff mbox series

[2/2] hdata/vpd: Remove possible dereference after null check (CID 207468)

Message ID 20180115051800.19398-2-cyril.bur@au1.ibm.com
State Accepted
Headers show
Series [1/2] core: Avoid possible uninitialized pointer read (CID 209502) | expand

Commit Message

Cyril Bur Jan. 15, 2018, 5:18 a.m. UTC
The next_extry label doesn't do anything other than perform an addition
which requires a dereference of the NULL entry variable, just continue
the loop instead.

Fixes: 77190aa7 (hdata/vpd: Rework vpd node creation logic)
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
---
 hdata/vpd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Vasant Hegde Jan. 17, 2018, 5:01 a.m. UTC | #1
On 01/15/2018 10:48 AM, Cyril Bur wrote:
> The next_extry label doesn't do anything other than perform an addition
> which requires a dereference of the NULL entry variable, just continue
> the loop instead.
> 
> Fixes: 77190aa7 (hdata/vpd: Rework vpd node creation logic)
> Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>

Looks good.

Reviewed-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>

-Vasant

> ---
>   hdata/vpd.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hdata/vpd.c b/hdata/vpd.c
> index d114e6b7..3eb7dcf2 100644
> --- a/hdata/vpd.c
> +++ b/hdata/vpd.c
> @@ -400,7 +400,7 @@ void dt_init_vpd_node(void)
>   		/* Get SLCA entry */
>   		entry = slca_get_entry(index);
>   		if (!entry)
> -			goto next_entry;
> +			continue;
> 
>   		/*
>   		 * A child entry is valid if all of the following criteria is met
>
Oliver O'Halloran Jan. 17, 2018, 5:20 a.m. UTC | #2
On Mon, Jan 15, 2018 at 4:18 PM, Cyril Bur <cyril.bur@au1.ibm.com> wrote:
> The next_extry label doesn't do anything other than perform an addition
> which requires a dereference of the NULL entry variable, just continue
> the loop instead.
>
> Fixes: 77190aa7 (hdata/vpd: Rework vpd node creation logic)
> Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
> ---
>  hdata/vpd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hdata/vpd.c b/hdata/vpd.c
> index d114e6b7..3eb7dcf2 100644
> --- a/hdata/vpd.c
> +++ b/hdata/vpd.c
> @@ -400,7 +400,7 @@ void dt_init_vpd_node(void)
>                 /* Get SLCA entry */
>                 entry = slca_get_entry(index);
>                 if (!entry)
> -                       goto next_entry;
> +                       continue;

<bikeshed>

WELL GIVEN THIS CAN ONLY HAPPEN IF WE GET AN OUT OF RANGE SLCA INDEX
IT DOESN'T REALLY MAKE ANY SENSE TO CONTINUE HERE. THIS SHOULD
PROBABLY BE A BREAK INSTEAD.

</bikeshed>

>
>                 /*
>                  * A child entry is valid if all of the following criteria is met
> --
> 2.15.1
>
diff mbox series

Patch

diff --git a/hdata/vpd.c b/hdata/vpd.c
index d114e6b7..3eb7dcf2 100644
--- a/hdata/vpd.c
+++ b/hdata/vpd.c
@@ -400,7 +400,7 @@  void dt_init_vpd_node(void)
 		/* Get SLCA entry */
 		entry = slca_get_entry(index);
 		if (!entry)
-			goto next_entry;
+			continue;
 
 		/*
 		 * A child entry is valid if all of the following criteria is met