Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/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
  • Loading branch information
torvalds committed Jan 6, 2019
2 parents 5c4a608 + 5f30b2e commit 1686cc1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions samples/livepatch/livepatch-shadow-fix1.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ struct dummy *livepatch_fix1_dummy_alloc(void)
* pointer to handle resource release.
*/
leak = kzalloc(sizeof(int), GFP_KERNEL);
if (!leak) {
kfree(d);
return NULL;
}

klp_shadow_alloc(d, SV_LEAK, sizeof(leak), GFP_KERNEL,
shadow_leak_ctor, leak);

Expand Down
4 changes: 4 additions & 0 deletions samples/livepatch/livepatch-shadow-mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1686cc1

Please sign in to comment.