Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev reorder initialization to improve error handling in ...
details: https://anonhg.NetBSD.org/src/rev/b4c8c29cc715
branches: trunk
changeset: 778509:b4c8c29cc715
user: drochner <drochner%NetBSD.org@localhost>
date: Fri Mar 30 20:15:18 2012 +0000
description:
reorder initialization to improve error handling in case the system
runs out of file descriptors, avoids LOCKDEBUG panic due to double
mutex initialization
diffstat:
sys/dev/rndpseudo.c | 13 ++++++-------
1 files changed, 6 insertions(+), 7 deletions(-)
diffs (38 lines):
diff -r 5c6bf228400d -r b4c8c29cc715 sys/dev/rndpseudo.c
--- a/sys/dev/rndpseudo.c Fri Mar 30 18:27:55 2012 +0000
+++ b/sys/dev/rndpseudo.c Fri Mar 30 20:15:18 2012 +0000
@@ -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 @@
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);
}
Home |
Main Index |
Thread Index |
Old Index