Acked-by: Eitan Eliahu <elia...@vmware.com>

-----Original Message-----
From: Samuel Ghinet [mailto:sghi...@cloudbasesolutions.com] 
Sent: Tuesday, September 30, 2014 8:03 AM
To: dev@openvswitch.org
Cc: Alin Serdean; Nithin Raju; Eitan Eliahu; Ankur Sharma
Subject: [PATCH 14/14] datapath-windows: Fix potential crash in 
OvsInitConfiguredSwitchNics: virtPort

If the hyper-v switch port type is external, then the function 
OvsInitConfiguredSwitchNics allocates a vport, and if allocation succeeds, it 
procedes with the initialization. However, at this point, virtPort may happen 
to be null, but check against virtPort was not made - this means that if 
virtPort was null, later on its fields would try to be accessed.

This patch adds a check for virtPort as well, so that the fields of virtPort 
will not be accessed if virtPort is NULL.

Signed-off-by: Samuel Ghinet <sghi...@cloudbasesolutions.com>
---
 datapath-windows/ovsext/Vport.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/datapath-windows/ovsext/Vport.c b/datapath-windows/ovsext/Vport.c 
index d90fd2b..1e05d60 100644
--- a/datapath-windows/ovsext/Vport.c
+++ b/datapath-windows/ovsext/Vport.c
@@ -857,10 +857,9 @@ OvsInitConfiguredSwitchNics(POVS_SWITCH_CONTEXT 
switchContext)
 
         if (nicParam->NicType == NdisSwitchNicTypeExternal &&
             nicParam->NicIndex != 0) {
-            POVS_VPORT_ENTRY virtVport =
-                   (POVS_VPORT_ENTRY)switchContext->externalVport;
+            POVS_VPORT_ENTRY virtVport = switchContext->externalVport;
             vport = OvsAllocateVport();
-            if (vport) {
+            if (vport && virtVport) {
                 OvsInitPhysNicVport(vport, virtVport, nicParam->NicIndex);
                 status = OvsInitVportCommon(switchContext, vport);
                 if (status != NDIS_STATUS_SUCCESS) {
--
1.8.3.msysgit.0

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to