link discovery clean up
diff --git a/providers/of/link/src/main/java/org/onlab/onos/provider/of/link/impl/LinkDiscovery.java b/providers/of/link/src/main/java/org/onlab/onos/provider/of/link/impl/LinkDiscovery.java
index ecb4765..dfff4d5 100644
--- a/providers/of/link/src/main/java/org/onlab/onos/provider/of/link/impl/LinkDiscovery.java
+++ b/providers/of/link/src/main/java/org/onlab/onos/provider/of/link/impl/LinkDiscovery.java
@@ -228,6 +228,9 @@
      * @return Packet_out message with LLDP data
      */
     private OFPacketOut createLLDPPacketOut(final OFPortDesc port) {
+        if (port == null) {
+            return null;
+        }
         OFPacketOut.Builder packetOut = this.ofFactory.buildPacketOut();
         packetOut.setBufferId(OFBufferId.NO_BUFFER);
         OFAction act = this.ofFactory.actions().buildOutput()
@@ -248,6 +251,9 @@
      * @return Packet_out message with LLDP data
      */
     private OFPacketOut createBDDPPacketOut(final OFPortDesc port) {
+        if (port == null) {
+            return null;
+        }
         OFPacketOut.Builder packetOut = sw.factory().buildPacketOut();
 
         packetOut.setBufferId(OFBufferId.NO_BUFFER);
@@ -267,6 +273,9 @@
 
 
     private void sendMsg(final OFMessage msg) {
+        if (msg == null) {
+            return;
+        }
         this.sw.sendMsg(msg);
     }
 
@@ -389,8 +398,8 @@
     }
 
     public void stop() {
-        removeAllPorts();
         timeout.cancel();
+        removeAllPorts();
     }
 
 }