Print this page
10093 kmem_log_enter() dereferences pointer before NULL check

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/kmem.c
          +++ new/usr/src/uts/common/os/kmem.c
↓ open down ↓ 1417 lines elided ↑ open up ↑
1418 1418          lhp->lh_head = max_ncpus;
1419 1419          lhp->lh_tail = 0;
1420 1420  
1421 1421          return (lhp);
1422 1422  }
1423 1423  
1424 1424  static void *
1425 1425  kmem_log_enter(kmem_log_header_t *lhp, void *data, size_t size)
1426 1426  {
1427 1427          void *logspace;
1428      -        kmem_cpu_log_header_t *clhp = &lhp->lh_cpu[CPU->cpu_seqid];
     1428 +        kmem_cpu_log_header_t *clhp;
1429 1429  
1430 1430          if (lhp == NULL || kmem_logging == 0 || panicstr)
1431 1431                  return (NULL);
1432 1432  
     1433 +        clhp = &lhp->lh_cpu[CPU->cpu_seqid];
     1434 +
1433 1435          mutex_enter(&clhp->clh_lock);
1434 1436          clhp->clh_hits++;
1435 1437          if (size > clhp->clh_avail) {
1436 1438                  mutex_enter(&lhp->lh_lock);
1437 1439                  lhp->lh_hits++;
1438 1440                  lhp->lh_free[lhp->lh_tail] = clhp->clh_chunk;
1439 1441                  lhp->lh_tail = (lhp->lh_tail + 1) % lhp->lh_nchunks;
1440 1442                  clhp->clh_chunk = lhp->lh_free[lhp->lh_head];
1441 1443                  lhp->lh_head = (lhp->lh_head + 1) % lhp->lh_nchunks;
1442 1444                  clhp->clh_current = lhp->lh_base +
↓ open down ↓ 3935 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX