[ovs-dev] [PATCH 14/14] datapath-windows: Fix potential crash in OvsInitConfiguredSwitchNics: virtPort
Samuel Ghinet
sghinet at cloudbasesolutions.com
Tue Sep 30 15:03:10 UTC 2014
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 <sghinet at 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
More information about the dev
mailing list