hc
2024-01-31 f9004dbfff8a3fbbd7e2a88c8a4327c7f2f8e5b2
kernel/samples/livepatch/livepatch-shadow-mod.c
....@@ -1,18 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * 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/>.
164 */
175
186 /*
....@@ -96,18 +84,18 @@
9684 * Keep a list of all the dummies so we can clean up any residual ones
9785 * on module exit
9886 */
99
-LIST_HEAD(dummy_list);
100
-DEFINE_MUTEX(dummy_list_mutex);
87
+static LIST_HEAD(dummy_list);
88
+static DEFINE_MUTEX(dummy_list_mutex);
10189
10290 struct dummy {
10391 struct list_head list;
10492 unsigned long jiffies_expire;
10593 };
10694
107
-noinline struct dummy *dummy_alloc(void)
95
+static __used noinline struct dummy *dummy_alloc(void)
10896 {
10997 struct dummy *d;
110
- void *leak;
98
+ int *leak;
11199
112100 d = kzalloc(sizeof(*d), GFP_KERNEL);
113101 if (!d)
....@@ -117,7 +105,7 @@
117105 msecs_to_jiffies(1000 * EXPIRE_PERIOD);
118106
119107 /* Oops, forgot to save leak! */
120
- leak = kzalloc(sizeof(int), GFP_KERNEL);
108
+ leak = kzalloc(sizeof(*leak), GFP_KERNEL);
121109 if (!leak) {
122110 kfree(d);
123111 return NULL;
....@@ -129,7 +117,7 @@
129117 return d;
130118 }
131119
132
-noinline void dummy_free(struct dummy *d)
120
+static __used noinline void dummy_free(struct dummy *d)
133121 {
134122 pr_info("%s: dummy @ %p, expired = %lx\n",
135123 __func__, d, d->jiffies_expire);
....@@ -137,7 +125,8 @@
137125 kfree(d);
138126 }
139127
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)
141130 {
142131 return time_after(jiffies, d->jiffies_expire);
143132 }