Print this page
5253 kmem_alloc/kmem_zalloc won't fail with KM_SLEEP
5254 getrbuf won't fail with KM_SLEEP

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/crypto/io/dca_rng.c
          +++ new/usr/src/uts/common/crypto/io/dca_rng.c
↓ open down ↓ 16 lines elided ↑ open up ↑
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26   26  
  27      -#pragma ident   "%Z%%M% %I%     %E% SMI"
  28      -
  29   27  /*
  30   28   * Deimos - cryptographic acceleration based upon Broadcom 582x.
  31   29   */
  32   30  
  33   31  #include <sys/types.h>
  34   32  #include <sys/ddi.h>
  35   33  #include <sys/sunddi.h>
  36   34  #include <sys/kmem.h>
  37   35  #include <sys/crypto/dca.h>
  38   36  #include <sys/atomic.h>
↓ open down ↓ 170 lines elided ↑ open up ↑
 209  207  
 210  208  #define RANDOM_BUFFER_SIZE              (1<<15)
 211  209  #define DCA_RANDOM_MAX_WAIT             10000
 212  210  
 213  211  int
 214  212  dca_random_init(dca_t *dca)
 215  213  {
 216  214          /* Mutex for the local random number pool */
 217  215          mutex_init(&dca->dca_random_lock, NULL, MUTEX_DRIVER, NULL);
 218  216  
 219      -        if ((dca->dca_buf1 = kmem_alloc(RANDOM_BUFFER_SIZE, KM_SLEEP)) ==
 220      -            NULL) {
 221      -                mutex_destroy(&dca->dca_random_lock);
 222      -                return (CRYPTO_FAILED);
 223      -        }
      217 +        dca->dca_buf1 = kmem_alloc(RANDOM_BUFFER_SIZE, KM_SLEEP);
 224  218  
 225      -        if ((dca->dca_buf2 = kmem_alloc(RANDOM_BUFFER_SIZE, KM_SLEEP)) ==
 226      -            NULL) {
 227      -                mutex_destroy(&dca->dca_random_lock);
 228      -                kmem_free(dca->dca_buf1, RANDOM_BUFFER_SIZE);
 229      -                return (CRYPTO_FAILED);
 230      -        }
      219 +        dca->dca_buf2 = kmem_alloc(RANDOM_BUFFER_SIZE, KM_SLEEP);
 231  220  
 232  221          return (CRYPTO_SUCCESS);
 233  222  }
 234  223  
 235  224  void
 236  225  dca_random_fini(dca_t *dca)
 237  226  {
 238  227          kmem_free(dca->dca_buf1, RANDOM_BUFFER_SIZE);
 239  228          kmem_free(dca->dca_buf2, RANDOM_BUFFER_SIZE);
 240  229          dca->dca_buf1 = dca->dca_buf2 = dca->dca_buf_ptr = NULL;
↓ open down ↓ 85 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX