net: sctp: sideeffect: throw BUG if primary_path is NULL
[firefly-linux-kernel-4.4.55.git] / net / sctp / proc.c
index 4e45ee35d0db149582c4435462baf253647d7774..0c83162a6bf812d970db058ad675924335e3a3eb 100644 (file)
@@ -134,9 +134,15 @@ static void sctp_seq_dump_local_addrs(struct seq_file *seq, struct sctp_ep_commo
        struct sctp_af *af;
 
        if (epb->type == SCTP_EP_TYPE_ASSOCIATION) {
-           asoc = sctp_assoc(epb);
-           peer = asoc->peer.primary_path;
-           primary = &peer->saddr;
+               asoc = sctp_assoc(epb);
+
+               peer = asoc->peer.primary_path;
+               if (unlikely(peer == NULL)) {
+                       WARN(1, "Association %p with NULL primary path!", asoc);
+                       return;
+               }
+
+               primary = &peer->saddr;
        }
 
        rcu_read_lock();