From f123f2ce18da0576fdc172a9998986f0057ad704 Mon Sep 17 00:00:00 2001 From: np Date: Sun, 20 Mar 2016 05:01:40 +0000 Subject: [PATCH] MFC r277759 (by jhb@) Fix a couple of panics when detaching from a cxgbe/cxl interface that was never brought up: - Allow NULL to be passed to sglist_free(). - Don't try to stop an interface that was never fully initialized. PR: 208136 --- sys/dev/cxgbe/t4_main.c | 6 ++++++ sys/kern/subr_sglist.c | 3 +++ 2 files changed, 9 insertions(+) diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index de4a380b311b..3dfb53f1efab 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -3250,6 +3250,12 @@ cxgbe_uninit_synchronized(struct port_info *pi) ASSERT_SYNCHRONIZED_OP(sc); + if (!(pi->flags & PORT_INIT_DONE)) { + KASSERT(!(ifp->if_drv_flags & IFF_DRV_RUNNING), + ("uninited port is running")); + return (0); + } + /* * Disable the VI so that all its data in either direction is discarded * by the MPS. Leave everything else (the queues, interrupts, and 1Hz diff --git a/sys/kern/subr_sglist.c b/sys/kern/subr_sglist.c index c66973a92c79..df88a26dc5ad 100644 --- a/sys/kern/subr_sglist.c +++ b/sys/kern/subr_sglist.c @@ -216,6 +216,9 @@ void sglist_free(struct sglist *sg) { + if (sg == NULL) + return; + if (refcount_release(&sg->sg_refs)) free(sg, M_SGLIST); }