Print this page
5552 libsun_sas leaks devids
Reviewed by: Alek Pinchuk <alek.pinchuk@nexenta.com>
Reviewed by: Jean McCormack <jean.mccormack@nexenta.com>
Reviewed by: Marcel Telka <marcel.telka@nexenta.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/sun_sas/common/devtree_device_disco.c
          +++ new/usr/src/lib/sun_sas/common/devtree_device_disco.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  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 2009 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
       25 + * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
  25   26   */
  26   27  
  27   28  #include        <sun_sas.h>
  28   29  #include        <sys/types.h>
  29   30  #include        <netinet/in.h>
  30   31  #include        <inttypes.h>
  31   32  #include        <ctype.h>
  32   33  #include        <sys/scsi/scsi_address.h>
  33   34  #include        <libdevid.h>
  34   35  
↓ open down ↓ 545 lines elided ↑ open up ↑
 580  581              "%s%s%s", DEVICES_DIR, devpath, minorname);
 581  582  
 582  583          /* reset errno to 0 */
 583  584          errno = 0;
 584  585          if (di_prop_lookup_strings(DDI_DEV_T_ANY, node, "devid",
 585  586              &propStringData) != -1) {
 586  587                  if (devid_str_decode(propStringData, &devid, NULL) != -1) {
 587  588                          guidStr = devid_to_guid(devid);
 588  589                          if (guidStr != NULL) {
 589  590                                  (void) strlcpy(mapping_ptr->entry.LUID.buffer,
 590      -                                    guidStr, 256);
      591 +                                    guidStr,
      592 +                                    sizeof (mapping_ptr->entry.LUID.buffer));
 591  593                                  devid_free_guid(guidStr);
 592  594                          } else {
 593  595                                  /*
 594  596                                   * Note:
 595  597                                   * if logical unit associated page 83 id
 596  598                                   * descriptor is not avaialble for the device
 597      -                                 * devid_to_guid returns NULl with errno 0.
      599 +                                 * devid_to_guid returns NULL with errno 0.
 598  600                                   */
 599  601                                  log(LOG_DEBUG, ROUTINE,
 600  602                                      "failed to get devid guid on (%s) : %s",
 601  603                                      devpath, strerror(errno));
 602  604                          }
      605 +
      606 +                        devid_free(devid);
 603  607                  } else {
 604  608                          /*
 605  609                           * device may not support proper page 83 id descriptor.
 606  610                           * leave LUID attribute to NULL and continue.
 607  611                           */
 608  612                          log(LOG_DEBUG, ROUTINE,
 609  613                              "failed to decode devid prop on (%s) : %s",
 610  614                              devpath, strerror(errno));
 611  615                  }
 612  616          } else {
↓ open down ↓ 385 lines elided ↑ open up ↑
 998 1002                          if (guidStr != NULL) {
 999 1003                                  (void) strlcpy(mapping_ptr->entry.LUID.buffer,
1000 1004                                      guidStr,
1001 1005                                      sizeof (mapping_ptr->entry.LUID.buffer));
1002 1006                                  devid_free_guid(guidStr);
1003 1007                          } else {
1004 1008                                  /*
1005 1009                                   * Note:
1006 1010                                   * if logical unit associated page 83 id
1007 1011                                   * descriptor is not avaialble for the device
1008      -                                 * devid_to_guid returns NULl with errno 0.
     1012 +                                 * devid_to_guid returns NULL with errno 0.
1009 1013                                   */
1010 1014                                  log(LOG_DEBUG, ROUTINE,
1011 1015                                      "failed to get devid guid on (%s)",
1012 1016                                      " associated with path(%s) : %s",
1013 1017                                      clientdevpath,
1014 1018                                      pathdevpath ?  pathdevpath :
1015 1019                                      "(missing device path)",
1016 1020                                      strerror(errno));
1017 1021                          }
     1022 +
     1023 +                        devid_free(devid);
1018 1024                  } else {
1019 1025                          /*
1020 1026                           * device may not support proper page 83 id descriptor.
1021 1027                           * leave LUID attribute to NULL and continue.
1022 1028                           */
1023 1029                          log(LOG_DEBUG, ROUTINE,
1024 1030                              "failed to decode devid prop on (%s)",
1025 1031                              " associated with path(%s) : %s",
1026 1032                              clientdevpath,
1027 1033                              pathdevpath ?  pathdevpath :
↓ open down ↓ 69 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX