diff options
| author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2019-07-10 23:24:10 -0700 |
|---|---|---|
| committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2019-07-10 23:24:10 -0700 |
| commit | 597473720f4dc69749542bfcfed4a927a43d935e (patch) | |
| tree | 711bf773910fb93d1dd9120c633adc807685e0d8 /samples/livepatch/livepatch-shadow-mod.c | |
| parent | f0dd687815f9546860fc3ac4379d55da045942c9 (diff) | |
| parent | 593fdd4fb44ef2cbf4ec53ec2c6eb60eb079bb4c (diff) | |
Merge branch 'next' into for-linus
Prepare input updates for 5.3 merge window.
Diffstat (limited to 'samples/livepatch/livepatch-shadow-mod.c')
| -rw-r--r-- | samples/livepatch/livepatch-shadow-mod.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/samples/livepatch/livepatch-shadow-mod.c b/samples/livepatch/livepatch-shadow-mod.c index 4c54b250332d..4d79c6dc055b 100644 --- a/samples/livepatch/livepatch-shadow-mod.c +++ b/samples/livepatch/livepatch-shadow-mod.c @@ -96,15 +96,15 @@ MODULE_DESCRIPTION("Buggy module for shadow variable demo"); * Keep a list of all the dummies so we can clean up any residual ones * on module exit */ -LIST_HEAD(dummy_list); -DEFINE_MUTEX(dummy_list_mutex); +static LIST_HEAD(dummy_list); +static DEFINE_MUTEX(dummy_list_mutex); struct dummy { struct list_head list; unsigned long jiffies_expire; }; -noinline struct dummy *dummy_alloc(void) +static __used noinline struct dummy *dummy_alloc(void) { struct dummy *d; void *leak; @@ -118,6 +118,10 @@ noinline struct dummy *dummy_alloc(void) /* Oops, forgot to save leak! */ leak = kzalloc(sizeof(int), GFP_KERNEL); + if (!leak) { + kfree(d); + return NULL; + } pr_info("%s: dummy @ %p, expires @ %lx\n", __func__, d, d->jiffies_expire); @@ -125,7 +129,7 @@ noinline struct dummy *dummy_alloc(void) return d; } -noinline void dummy_free(struct dummy *d) +static __used noinline void dummy_free(struct dummy *d) { pr_info("%s: dummy @ %p, expired = %lx\n", __func__, d, d->jiffies_expire); @@ -133,7 +137,8 @@ noinline void dummy_free(struct dummy *d) kfree(d); } -noinline bool dummy_check(struct dummy *d, unsigned long jiffies) +static __used noinline bool dummy_check(struct dummy *d, + unsigned long jiffies) { return time_after(jiffies, d->jiffies_expire); } |
