Print this page
10145 smbios_info_boot() 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) 2017, Joyent, Inc.
       24 + * Copyright (c) 2018, 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 ↓ 941 lines elided ↑ open up ↑
 976  976          hsp->smbh_adm_ps = SMB_HWS_ADM_PS(hs.smbhs_settings);
 977  977          hsp->smbh_pan_ps = SMB_HWS_PAN_PS(hs.smbhs_settings);
 978  978  
 979  979          return (stp->smbst_hdr->smbh_hdl);
 980  980  }
 981  981  
 982  982  id_t
 983  983  smbios_info_boot(smbios_hdl_t *shp, smbios_boot_t *bp)
 984  984  {
 985  985          const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_BOOT);
 986      -        const smb_boot_t *b = (smb_boot_t *)(uintptr_t)stp->smbst_hdr;
      986 +        const smb_boot_t *b;
 987  987  
 988  988          if (stp == NULL)
 989  989                  return (-1); /* errno is set for us */
 990  990  
 991  991          bzero(bp, sizeof (smbios_boot_t));
 992  992  
      993 +        b = (smb_boot_t *)(uintptr_t)stp->smbst_hdr;
      994 +
 993  995          bp->smbt_status = b->smbbo_status[0];
 994  996          bp->smbt_size = stp->smbst_hdr->smbh_len - sizeof (smb_boot_t);
 995  997          bp->smbt_data = bp->smbt_size ? &b->smbbo_status[1] : NULL;
 996  998  
 997  999          return (stp->smbst_hdr->smbh_hdl);
 998 1000  }
 999 1001  
1000 1002  id_t
1001 1003  smbios_info_ipmi(smbios_hdl_t *shp, smbios_ipmi_t *ip)
1002 1004  {
↓ open down ↓ 470 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX