summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Telka <Marcel.Telka@Sun.COM>2009-09-01 06:38:59 +0200
committerMarcel Telka <Marcel.Telka@Sun.COM>2009-09-01 06:38:59 +0200
commit38f9230374f68e497735c3b79c1caed0ef10abda (patch)
tree61822c9009bbfc934bfcb3dd5931ff721f133d1d
parent564a03c8130e6cc4a56f3a5289a4a36a672b0412 (diff)
downloadillumos-joyent-38f9230374f68e497735c3b79c1caed0ef10abda.tar.gz
6873852 nfsstat dies due to uninitialized ksum_kstat
-rw-r--r--usr/src/cmd/fs.d/nfs/nfsstat/nfsstat.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/usr/src/cmd/fs.d/nfs/nfsstat/nfsstat.c b/usr/src/cmd/fs.d/nfs/nfsstat/nfsstat.c
index 195a2bb5d5..fe95ba6806 100644
--- a/usr/src/cmd/fs.d/nfs/nfsstat/nfsstat.c
+++ b/usr/src/cmd/fs.d/nfs/nfsstat/nfsstat.c
@@ -510,8 +510,8 @@ setup(void)
if ((kc = kstat_open()) == NULL)
fail(1, "kstat_open(): can't open /dev/kstat");
- /* malloc space for our temporary kstat */
- ksum_kstat = malloc(sizeof (kstat_t));
+ /* alloc space for our temporary kstat */
+ safe_zalloc((void **)&ksum_kstat, sizeof (kstat_t), 0);
rpc_clts_client_kstat = kstat_lookup(kc, "unix", 0, "rpc_clts_client");
rpc_clts_server_kstat = kstat_lookup(kc, "unix", 0, "rpc_clts_server");
rpc_cots_client_kstat = kstat_lookup(kc, "unix", 0, "rpc_cots_client");
@@ -1424,14 +1424,13 @@ nfsstat_kstat_copy(kstat_t *src, kstat_t *dst, int fr)
}
/*
- * "Safe" allocators - if we return we're guaranteed
- * to have the desired space. We exit via fail
- * if we can't get the space.
+ * "Safe" allocators - if we return we're guaranteed to have the desired space
+ * allocated and zero-filled. We exit via fail if we can't get the space.
*/
void
safe_zalloc(void **ptr, uint_t size, int free_first)
{
- if (*ptr == NULL)
+ if (ptr == NULL)
fail(1, "invalid pointer");
if (free_first && *ptr != NULL)
free(*ptr);