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/fs/zfs/sa.c
          +++ new/usr/src/uts/common/fs/zfs/sa.c
↓ open down ↓ 397 lines elided ↑ open up ↑
 398  398          }
 399  399          return (error);
 400  400  }
 401  401  
 402  402  static sa_lot_t *
 403  403  sa_add_layout_entry(objset_t *os, sa_attr_type_t *attrs, int attr_count,
 404  404      uint64_t lot_num, uint64_t hash, boolean_t zapadd, dmu_tx_t *tx)
 405  405  {
 406  406          sa_os_t *sa = os->os_sa;
 407  407          sa_lot_t *tb, *findtb;
 408      -        int i;
      408 +        int i, size;
 409  409          avl_index_t loc;
 410  410  
 411  411          ASSERT(MUTEX_HELD(&sa->sa_lock));
 412  412          tb = kmem_zalloc(sizeof (sa_lot_t), KM_SLEEP);
 413  413          tb->lot_attr_count = attr_count;
 414      -        tb->lot_attrs = kmem_alloc(sizeof (sa_attr_type_t) * attr_count,
 415      -            KM_SLEEP);
 416      -        bcopy(attrs, tb->lot_attrs, sizeof (sa_attr_type_t) * attr_count);
      414 +
      415 +        if ((size = sizeof (sa_attr_type_t) * attr_count) != 0) {
      416 +                tb->lot_attrs = kmem_alloc(size, KM_SLEEP);
      417 +                bcopy(attrs, tb->lot_attrs, size);
      418 +        }
      419 +
 417  420          tb->lot_num = lot_num;
 418  421          tb->lot_hash = hash;
 419  422          tb->lot_instance = 0;
 420  423  
 421  424          if (zapadd) {
 422  425                  char attr_name[8];
 423  426  
 424  427                  if (sa->sa_layout_attr_obj == 0) {
 425  428                          sa->sa_layout_attr_obj = zap_create_link(os,
 426  429                              DMU_OT_SA_ATTR_LAYOUTS,
↓ open down ↓ 1764 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX