| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2017 Joe Lawrence <joe.lawrence@redhat.com> |
|---|
| 3 | | - * |
|---|
| 4 | | - * This program is free software; you can redistribute it and/or |
|---|
| 5 | | - * modify it under the terms of the GNU General Public License |
|---|
| 6 | | - * as published by the Free Software Foundation; either version 2 |
|---|
| 7 | | - * of the License, or (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 | 4 | */ |
|---|
| 17 | 5 | |
|---|
| 18 | 6 | /* |
|---|
| .. | .. |
|---|
| 96 | 84 | * Keep a list of all the dummies so we can clean up any residual ones |
|---|
| 97 | 85 | * on module exit |
|---|
| 98 | 86 | */ |
|---|
| 99 | | -LIST_HEAD(dummy_list); |
|---|
| 100 | | -DEFINE_MUTEX(dummy_list_mutex); |
|---|
| 87 | +static LIST_HEAD(dummy_list); |
|---|
| 88 | +static DEFINE_MUTEX(dummy_list_mutex); |
|---|
| 101 | 89 | |
|---|
| 102 | 90 | struct dummy { |
|---|
| 103 | 91 | struct list_head list; |
|---|
| 104 | 92 | unsigned long jiffies_expire; |
|---|
| 105 | 93 | }; |
|---|
| 106 | 94 | |
|---|
| 107 | | -noinline struct dummy *dummy_alloc(void) |
|---|
| 95 | +static __used noinline struct dummy *dummy_alloc(void) |
|---|
| 108 | 96 | { |
|---|
| 109 | 97 | struct dummy *d; |
|---|
| 110 | | - void *leak; |
|---|
| 98 | + int *leak; |
|---|
| 111 | 99 | |
|---|
| 112 | 100 | d = kzalloc(sizeof(*d), GFP_KERNEL); |
|---|
| 113 | 101 | if (!d) |
|---|
| .. | .. |
|---|
| 117 | 105 | msecs_to_jiffies(1000 * EXPIRE_PERIOD); |
|---|
| 118 | 106 | |
|---|
| 119 | 107 | /* Oops, forgot to save leak! */ |
|---|
| 120 | | - leak = kzalloc(sizeof(int), GFP_KERNEL); |
|---|
| 108 | + leak = kzalloc(sizeof(*leak), GFP_KERNEL); |
|---|
| 121 | 109 | if (!leak) { |
|---|
| 122 | 110 | kfree(d); |
|---|
| 123 | 111 | return NULL; |
|---|
| .. | .. |
|---|
| 129 | 117 | return d; |
|---|
| 130 | 118 | } |
|---|
| 131 | 119 | |
|---|
| 132 | | -noinline void dummy_free(struct dummy *d) |
|---|
| 120 | +static __used noinline void dummy_free(struct dummy *d) |
|---|
| 133 | 121 | { |
|---|
| 134 | 122 | pr_info("%s: dummy @ %p, expired = %lx\n", |
|---|
| 135 | 123 | __func__, d, d->jiffies_expire); |
|---|
| .. | .. |
|---|
| 137 | 125 | kfree(d); |
|---|
| 138 | 126 | } |
|---|
| 139 | 127 | |
|---|
| 140 | | -noinline bool dummy_check(struct dummy *d, unsigned long jiffies) |
|---|
| 128 | +static __used noinline bool dummy_check(struct dummy *d, |
|---|
| 129 | + unsigned long jiffies) |
|---|
| 141 | 130 | { |
|---|
| 142 | 131 | return time_after(jiffies, d->jiffies_expire); |
|---|
| 143 | 132 | } |
|---|