Sat Apr 4 18:51:58 2015 UTC ()
lib/49813: Release mutex on error.


(joerg)
diff -r1.175 -r1.176 src/libexec/ld.elf_so/rtld.c

cvs diff -r1.175 -r1.176 src/libexec/ld.elf_so/rtld.c (expand / switch to unified diff)

--- src/libexec/ld.elf_so/rtld.c 2015/03/05 09:49:53 1.175
+++ src/libexec/ld.elf_so/rtld.c 2015/04/04 18:51:57 1.176
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: rtld.c,v 1.175 2015/03/05 09:49:53 skrll Exp $ */ 1/* $NetBSD: rtld.c,v 1.176 2015/04/04 18:51:57 joerg Exp $ */
2 2
3/* 3/*
4 * Copyright 1996 John D. Polstra. 4 * Copyright 1996 John D. Polstra.
5 * Copyright 1996 Matt Thomas <matt@3am-software.com> 5 * Copyright 1996 Matt Thomas <matt@3am-software.com>
6 * Copyright 2002 Charles M. Hannum <root@ihack.net> 6 * Copyright 2002 Charles M. Hannum <root@ihack.net>
7 * All rights reserved. 7 * All rights reserved.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -30,27 +30,27 @@ @@ -30,27 +30,27 @@
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */ 33 */
34 34
35/* 35/*
36 * Dynamic linker for ELF. 36 * Dynamic linker for ELF.
37 * 37 *
38 * John Polstra <jdp@polstra.com>. 38 * John Polstra <jdp@polstra.com>.
39 */ 39 */
40 40
41#include <sys/cdefs.h> 41#include <sys/cdefs.h>
42#ifndef lint 42#ifndef lint
43__RCSID("$NetBSD: rtld.c,v 1.175 2015/03/05 09:49:53 skrll Exp $"); 43__RCSID("$NetBSD: rtld.c,v 1.176 2015/04/04 18:51:57 joerg Exp $");
44#endif /* not lint */ 44#endif /* not lint */
45 45
46#include <sys/param.h> 46#include <sys/param.h>
47#include <sys/atomic.h> 47#include <sys/atomic.h>
48#include <sys/mman.h> 48#include <sys/mman.h>
49#include <err.h> 49#include <err.h>
50#include <errno.h> 50#include <errno.h>
51#include <fcntl.h> 51#include <fcntl.h>
52#include <lwp.h> 52#include <lwp.h>
53#include <stdarg.h> 53#include <stdarg.h>
54#include <stdio.h> 54#include <stdio.h>
55#include <stdlib.h> 55#include <stdlib.h>
56#include <string.h> 56#include <string.h>
@@ -1259,27 +1259,27 @@ dladdr(const void *addr, Dl_info *info) @@ -1259,27 +1259,27 @@ dladdr(const void *addr, Dl_info *info)
1259#endif 1259#endif
1260 1260
1261 dbg(("dladdr of %p", addr)); 1261 dbg(("dladdr of %p", addr));
1262 1262
1263 lookup_mutex_enter(); 1263 lookup_mutex_enter();
1264 1264
1265#ifdef __HAVE_FUNCTION_DESCRIPTORS 1265#ifdef __HAVE_FUNCTION_DESCRIPTORS
1266 addr = _rtld_function_descriptor_function(addr); 1266 addr = _rtld_function_descriptor_function(addr);
1267#endif /* __HAVE_FUNCTION_DESCRIPTORS */ 1267#endif /* __HAVE_FUNCTION_DESCRIPTORS */
1268 1268
1269 obj = _rtld_obj_from_addr(addr); 1269 obj = _rtld_obj_from_addr(addr);
1270 if (obj == NULL) { 1270 if (obj == NULL) {
1271 _rtld_error("No shared object contains address"); 1271 _rtld_error("No shared object contains address");
1272 lookup_mutex_enter(); 1272 lookup_mutex_exit();
1273 return 0; 1273 return 0;
1274 } 1274 }
1275 info->dli_fname = obj->path; 1275 info->dli_fname = obj->path;
1276 info->dli_fbase = obj->mapbase; 1276 info->dli_fbase = obj->mapbase;
1277 info->dli_saddr = (void *)0; 1277 info->dli_saddr = (void *)0;
1278 info->dli_sname = NULL; 1278 info->dli_sname = NULL;
1279 1279
1280 /* 1280 /*
1281 * Walk the symbol list looking for the symbol whose address is 1281 * Walk the symbol list looking for the symbol whose address is
1282 * closest to the address sent in. 1282 * closest to the address sent in.
1283 */ 1283 */
1284 best_def = NULL; 1284 best_def = NULL;
1285 for (symoffset = 0; symoffset < obj->nchains; symoffset++) { 1285 for (symoffset = 0; symoffset < obj->nchains; symoffset++) {