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>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/fibre-channel/impl/fctl.c
          +++ new/usr/src/uts/common/io/fibre-channel/impl/fctl.c
↓ open down ↓ 16 lines elided ↑ open up ↑
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
  24   24   */
  25   25  /*
  26   26   * Copyright 2012 Garrett D'Amore <garrett@damore.org>.  All rights reserved.
       27 + * Copyright (c) 2015 Joyent, Inc.  All rights reserved.
  27   28   */
  28   29  /*
  29   30   * Fibre channel Transport Library (fctl)
  30   31   *
  31   32   * Function naming conventions:
  32   33   *              Functions called from ULPs begin with fc_ulp_
  33   34   *              Functions called from FCAs begin with fc_fca_
  34   35   *              Internal functions begin with fctl_
  35   36   *
  36   37   * Fibre channel packet layout:
↓ open down ↓ 5456 lines elided ↑ open up ↑
5493 5494          ASSERT(pathList != NULL);
5494 5495  
5495 5496          /* First figure out how many ports we have */
5496 5497          mutex_enter(&fctl_port_lock);
5497 5498  
5498 5499          for (fca_port = fctl_fca_portlist; fca_port != NULL;
5499 5500              fca_port = fca_port->port_next) {
5500 5501                  maxPorts ++;
5501 5502          }
5502 5503  
     5504 +        if (maxPorts == 0) {
     5505 +                mutex_exit(&fctl_port_lock);
     5506 +                return (0);
     5507 +        }
     5508 +
5503 5509          /* Now allocate a buffer to store all the pointers for comparisons */
5504 5510          portList = kmem_zalloc(sizeof (fc_local_port_t *) * maxPorts, KM_SLEEP);
5505 5511  
5506 5512          for (fca_port = fctl_fca_portlist; fca_port != NULL;
5507 5513              fca_port = fca_port->port_next) {
5508 5514                  skip = 0;
5509 5515  
5510 5516                  /* Lock the new port for subsequent comparisons */
5511 5517                  new_port = fca_port->port_handle;
5512 5518                  mutex_enter(&new_port->fp_mutex);
↓ open down ↓ 1228 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX