Print this page
11416 smbios_info_slot_peers() gets NULL check wrong

Split Close
Expand all
Collapse all
          --- old/usr/src/common/smbios/smb_info.c
          +++ new/usr/src/common/smbios/smb_info.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2015 OmniTI Computer Consulting, Inc.  All rights reserved.
  24      - * Copyright (c) 2018, Joyent, Inc.
       24 + * Copyright 2019 Joyent, Inc.
  25   25   * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  26   26   * Use is subject to license terms.
  27   27   */
  28   28  
  29   29  /*
  30   30   * SMBIOS Information Routines
  31   31   *
  32   32   * The routines in this file are used to convert from the SMBIOS data format to
  33   33   * a more reasonable and stable set of structures offered as part of our ABI.
  34   34   * These functions take the general form:
↓ open down ↓ 656 lines elided ↑ open up ↑
 691  691          }
 692  692  
 693  693          smb_free(peer, sz);
 694  694  }
 695  695  
 696  696  int
 697  697  smbios_info_slot_peers(smbios_hdl_t *shp, id_t id, uint_t *npeers,
 698  698      smbios_slot_peer_t **peerp)
 699  699  {
 700  700          const smb_struct_t *stp = smb_lookup_id(shp, id);
 701      -        const smb_slot_t *slotp = (const smb_slot_t *)stp->smbst_hdr;
      701 +        const smb_slot_t *slotp;
 702  702          smbios_slot_peer_t *peer;
 703  703          size_t minlen;
 704  704          uint_t i;
 705  705  
 706  706          if (stp == NULL)
 707  707                  return (-1); /* errno is set for us */
 708  708  
      709 +        slotp = (const smb_slot_t *)stp->smbst_hdr;
      710 +
 709  711          if (stp->smbst_hdr->smbh_type != SMB_TYPE_SLOT)
 710  712                  return (smb_set_errno(shp, ESMB_TYPE));
 711  713  
 712  714          if (stp->smbst_hdr->smbh_len <= offsetof(smb_slot_t, smbsl_npeers) ||
 713  715              slotp->smbsl_npeers == 0) {
 714  716                  *npeers = 0;
 715  717                  *peerp = NULL;
 716  718                  return (0);
 717  719          }
 718  720  
↓ open down ↓ 845 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX