• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include <sys/mman.h>
19 #include "test.h"
20 #include "tst_get_bad_addr.h"
21 
tst_get_bad_addr(void (* cleanup_fn)(void))22 void *tst_get_bad_addr(void (*cleanup_fn) (void))
23 {
24 	void *bad_addr;
25 
26 	bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
27 	if (bad_addr == MAP_FAILED)
28 		tst_brkm(TBROK, cleanup_fn, "mmap() failed to get bad address");
29 
30 	return bad_addr;
31 }
32