Print this page
11227 smb code needs smatch fixes

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/smbsrv/smb_alloc.c
          +++ new/usr/src/uts/common/fs/smbsrv/smb_alloc.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   * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  23   23   */
  24   24  
       25 +/*
       26 + * Copyright 2019 Joyent, Inc.
       27 + */
       28 +
  25   29  #include <sys/types.h>
  26   30  #include <sys/sunddi.h>
  27   31  #include <sys/kmem.h>
  28   32  #include <sys/sysmacros.h>
  29   33  #include <smbsrv/smb_kproto.h>
  30   34  #include <smbsrv/alloc.h>
  31   35  
  32   36  #define SMB_SMH_MAGIC           0x534D485F      /* 'SMH_' */
  33   37  #define SMB_SMH_VALID(_smh_)    ASSERT((_smh_)->smh_magic == SMB_SMH_MAGIC)
  34   38  #define SMB_MEM2SMH(_mem_)      ((smb_mem_header_t *)(_mem_) - 1)
↓ open down ↓ 253 lines elided ↑ open up ↑
 288  292  
 289  293          smh = SMB_MEM2SMH(ptr);
 290  294          SMB_SMH_VALID(smh);
 291  295          ASSERT(sr == smh->smh_sr);
 292  296  
 293  297          if (size == 0) {
 294  298                  smb_free(sr, ptr, zero);
 295  299                  return (NULL);
 296  300          }
 297  301          if (smh->smh_size >= size) {
 298      -                if ((zero) & (smh->smh_size > size))
      302 +                if ((zero) && (smh->smh_size > size))
 299  303                          bzero((caddr_t)ptr + size, smh->smh_size - size);
 300  304                  return (ptr);
 301  305          }
 302  306          new_ptr = smb_alloc(sr, size, B_FALSE);
 303  307          bcopy(ptr, new_ptr, smh->smh_size);
 304  308          if (zero)
 305  309                  bzero((caddr_t)new_ptr + smh->smh_size, size - smh->smh_size);
 306  310  
 307  311          smb_free(sr, ptr, zero);
 308  312          return (new_ptr);
 309  313  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX