From 3921d26300cb61e31657c1732fff92dad6b91712 Mon Sep 17 00:00:00 2001 From: Anschel Schaffer-Cohen Date: Fri, 21 Jan 2011 10:14:43 -0500 Subject: [PATCH] Use defer to unlock mutex in crypto/rand. R=agl1 CC=golang-dev https://golang.org/cl/3991045 --- src/pkg/crypto/rand/rand_unix.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pkg/crypto/rand/rand_unix.go b/src/pkg/crypto/rand/rand_unix.go index ff16f25547..900b573305 100644 --- a/src/pkg/crypto/rand/rand_unix.go +++ b/src/pkg/crypto/rand/rand_unix.go @@ -29,15 +29,14 @@ type devReader struct { func (r *devReader) Read(b []byte) (n int, err os.Error) { r.mu.Lock() + defer r.mu.Unlock() if r.f == nil { f, err := os.Open(r.name, os.O_RDONLY, 0) if f == nil { - r.mu.Unlock() return 0, err } r.f = f } - r.mu.Unlock() return r.f.Read(b) }