Skip to content

Commit 1686cc1

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/livepatching
Pull livepatch update from Jiri Kosina: "Return value checking fixup in livepatching samples, from Nicholas Mc Guire" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/livepatching: livepatch: check kzalloc return values
2 parents 5c4a608 + 5f30b2e commit 1686cc1

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

samples/livepatch/livepatch-shadow-fix1.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ struct dummy *livepatch_fix1_dummy_alloc(void)
8989
* pointer to handle resource release.
9090
*/
9191
leak = kzalloc(sizeof(int), GFP_KERNEL);
92+
if (!leak) {
93+
kfree(d);
94+
return NULL;
95+
}
96+
9297
klp_shadow_alloc(d, SV_LEAK, sizeof(leak), GFP_KERNEL,
9398
shadow_leak_ctor, leak);
9499

samples/livepatch/livepatch-shadow-mod.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ noinline struct dummy *dummy_alloc(void)
118118

119119
/* Oops, forgot to save leak! */
120120
leak = kzalloc(sizeof(int), GFP_KERNEL);
121+
if (!leak) {
122+
kfree(d);
123+
return NULL;
124+
}
121125

122126
pr_info("%s: dummy @ %p, expires @ %lx\n",
123127
__func__, d, d->jiffies_expire);

0 commit comments

Comments
 (0)