Module Name: src Committed By: drochner Date: Fri Mar 30 20:15:19 UTC 2012
Modified Files: src/sys/dev: rndpseudo.c Log Message: reorder initialization to improve error handling in case the system runs out of file descriptors, avoids LOCKDEBUG panic due to double mutex initialization To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/dev/rndpseudo.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/rndpseudo.c diff -u src/sys/dev/rndpseudo.c:1.6 src/sys/dev/rndpseudo.c:1.7 --- src/sys/dev/rndpseudo.c:1.6 Tue Dec 20 13:42:19 2011 +++ src/sys/dev/rndpseudo.c Fri Mar 30 20:15:18 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: rndpseudo.c,v 1.6 2011/12/20 13:42:19 apb Exp $ */ +/* $NetBSD: rndpseudo.c,v 1.7 2012/03/30 20:15:18 drochner Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rndpseudo.c,v 1.6 2011/12/20 13:42:19 apb Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rndpseudo.c,v 1.7 2012/03/30 20:15:18 drochner Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -213,15 +213,14 @@ rndopen(dev_t dev, int flag, int ifmt, default: return ENXIO; } - ctx = pool_cache_get(rp_cpc, PR_WAITOK); - ctx->cprng = NULL; - ctx->hard = hard; - mutex_init(&ctx->interlock, MUTEX_DEFAULT, IPL_NONE); - + ctx = pool_cache_get(rp_cpc, PR_WAITOK); if ((error = fd_allocfile(&fp, &fd)) != 0) { pool_cache_put(rp_cpc, ctx); return error; } + ctx->cprng = NULL; + ctx->hard = hard; + mutex_init(&ctx->interlock, MUTEX_DEFAULT, IPL_NONE); return fd_clone(fp, fd, flag, &rnd_fileops, ctx); }