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/os/smb_subr.c
          +++ new/usr/src/uts/common/os/smb_subr.c
↓ open down ↓ 17 lines elided ↑ open up ↑
  18   18   * information: Portions Copyright [yyyy] [name of copyright owner]
  19   19   *
  20   20   * CDDL HEADER END
  21   21   */
  22   22  
  23   23  /*
  24   24   * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
  25   25   * Use is subject to license terms.
  26   26   */
  27   27  
  28      -#pragma ident   "%Z%%M% %I%     %E% SMI"
       28 +/*
       29 + * Copyright (c) 2015 Joyent, Inc.  All rights reserved.
       30 + */
  29   31  
  30   32  #include <sys/smbios_impl.h>
  31   33  #include <sys/cmn_err.h>
  32   34  #include <sys/varargs.h>
  33   35  #include <sys/systm.h>
  34   36  #include <sys/kmem.h>
  35   37  
  36   38  /*ARGSUSED*/
  37   39  const char *
  38   40  smb_strerror(int err)
  39   41  {
  40   42          return (NULL);
  41   43  }
  42   44  
  43   45  void *
  44   46  smb_alloc(size_t len)
  45   47  {
  46      -        return (kmem_alloc(len, KM_SLEEP));
       48 +        return (len > 0 ? kmem_alloc(len, KM_SLEEP) : NULL);
  47   49  }
  48   50  
  49   51  void *
  50   52  smb_zalloc(size_t len)
  51   53  {
  52      -        return (kmem_zalloc(len, KM_SLEEP));
       54 +        return (len > 0 ? kmem_zalloc(len, KM_SLEEP) : NULL);
  53   55  }
  54   56  
  55   57  void
  56   58  smb_free(void *buf, size_t len)
  57   59  {
  58   60          kmem_free(buf, len);
  59   61  }
  60   62  
  61   63  /*PRINTFLIKE2*/
  62   64  void
↓ open down ↓ 11 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX