Print this page
11927 Log, or optionally panic, on zero-length kmem allocations
Reviewed by: Dan McDonald <danmcd@joyent.com>
Reviewed by: Jason King <jason.brian.king@gmail.com>

@@ -22,10 +22,11 @@
  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 /*
  * Copyright 2012 Garrett D'Amore <garrett@damore.org>.  All rights reserved.
+ * Copyright (c) 2015 Joyent, Inc.  All rights reserved.
  */
 /*
  * Fibre channel Transport Library (fctl)
  *
  * Function naming conventions:

@@ -5498,10 +5499,15 @@
         for (fca_port = fctl_fca_portlist; fca_port != NULL;
             fca_port = fca_port->port_next) {
                 maxPorts ++;
         }
 
+        if (maxPorts == 0) {
+                mutex_exit(&fctl_port_lock);
+                return (0);
+        }
+
         /* Now allocate a buffer to store all the pointers for comparisons */
         portList = kmem_zalloc(sizeof (fc_local_port_t *) * maxPorts, KM_SLEEP);
 
         for (fca_port = fctl_fca_portlist; fca_port != NULL;
             fca_port = fca_port->port_next) {