[ovs-dev,v2,4/7] datapath-windows: Add assert to ethHdr in OvsActionMplsPush

Message ID 20171106153339.10100-4-aserdean@ovn.org
State New
Headers show
Series
  • [ovs-dev,v2,1/7] datapath-windows: Use only non executable memory
Related show

Commit Message

Alin Gabriel Serdean Nov. 6, 2017, 3:33 p.m.
From: Alin Serdean <aserdean@cloudbasesolutions.com>

`ethHdr` cannot be NULL because we did a partial copy before it.

Add an assert to keep the static analysis happy.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
---
v2: switch from if to assert
---
 datapath-windows/ovsext/Actions.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Shashank Ram Nov. 7, 2017, 2:12 a.m. | #1
On Mon, Nov 6, 2017 at 7:33 AM, Alin Gabriel Serdean <aserdean@ovn.org>
wrote:

> From: Alin Serdean <aserdean@cloudbasesolutions.com>
>
> `ethHdr` cannot be NULL because we did a partial copy before it.
>
> Add an assert to keep the static analysis happy.
>
> Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
> ---
> v2: switch from if to assert
> ---
>  datapath-windows/ovsext/Actions.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/datapath-windows/ovsext/Actions.c b/datapath-windows/ovsext/
> Actions.c
> index 0af4a66..9bbc787 100644
> --- a/datapath-windows/ovsext/Actions.c
> +++ b/datapath-windows/ovsext/Actions.c
> @@ -1237,6 +1237,7 @@ OvsActionMplsPush(OvsForwardingContext *ovsFwdCtx,
>      ASSERT(mdlLen >= MPLS_HLEN);
>
>      ethHdr = (EthHdr *)(bufferStart + curMdlOffset);
> +    ASSERT(ethHdr);
>      RtlMoveMemory(ethHdr, (UINT8*)ethHdr + MPLS_HLEN, sizeof(*ethHdr));
>      ethHdr->Type = mpls->mpls_ethertype;
>
> --
> 2.10.2.windows.1
>
> _______________________________________________
> Acked-by: Shashank Ram <shashank08@gmail.com>
>

Patch

diff --git a/datapath-windows/ovsext/Actions.c b/datapath-windows/ovsext/Actions.c
index 0af4a66..9bbc787 100644
--- a/datapath-windows/ovsext/Actions.c
+++ b/datapath-windows/ovsext/Actions.c
@@ -1237,6 +1237,7 @@  OvsActionMplsPush(OvsForwardingContext *ovsFwdCtx,
     ASSERT(mdlLen >= MPLS_HLEN);
 
     ethHdr = (EthHdr *)(bufferStart + curMdlOffset);
+    ASSERT(ethHdr);
     RtlMoveMemory(ethHdr, (UINT8*)ethHdr + MPLS_HLEN, sizeof(*ethHdr));
     ethHdr->Type = mpls->mpls_ethertype;