Print this page
12001 cpu_uarray_free(NULL) panics

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/cpu_uarray.c
          +++ new/usr/src/uts/common/os/cpu_uarray.c
↓ open down ↓ 2 lines elided ↑ open up ↑
   3    3   * Common Development and Distribution License ("CDDL"), version 1.0.
   4    4   * You may only use this file in accordance with the terms of version
   5    5   * 1.0 of the CDDL.
   6    6   *
   7    7   * A full copy of the text of the CDDL should have accompanied this
   8    8   * source.  A copy of the CDDL is also available via the Internet at
   9    9   * http://www.illumos.org/license/CDDL.
  10   10   */
  11   11  
  12   12  /*
  13      - * Copyright (c) 2018, Joyent, Inc.
       13 + * Copyright 2019 Joyent, Inc.
  14   14   */
  15   15  
  16   16  #include <sys/cpu_uarray.h>
  17   17  #include <sys/sysmacros.h>
  18   18  #include <sys/cpuvar.h>
  19   19  #include <sys/debug.h>
  20   20  #include <sys/kmem.h>
  21   21  
  22   22  static size_t
  23   23  cpu_uarray_size(size_t nr_items)
↓ open down ↓ 14 lines elided ↑ open up ↑
  38   38                  VERIFY(IS_P2ALIGNED(cua->cu_vals, CUA_ALIGN));
  39   39                  cua->cu_nr_items = nr_items;
  40   40          }
  41   41  
  42   42          return (cua);
  43   43  }
  44   44  
  45   45  void
  46   46  cpu_uarray_free(cpu_uarray_t *cua)
  47   47  {
  48      -        kmem_free(cua, cpu_uarray_size(cua->cu_nr_items));
       48 +        if (cua != NULL)
       49 +                kmem_free(cua, cpu_uarray_size(cua->cu_nr_items));
  49   50  }
  50   51  
  51   52  uint64_t
  52   53  cpu_uarray_sum(cpu_uarray_t *cua, size_t index)
  53   54  {
  54   55          uint64_t sum = 0;
  55   56  
  56   57          VERIFY3U(index, <, cua->cu_nr_items);
  57   58  
  58   59          for (size_t c = 0; c < ncpus; c++) {
↓ open down ↓ 21 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX