livepatch: check kzalloc return values
[linux-2.6-microblaze.git] / samples / livepatch / livepatch-shadow-mod.c
index 4c54b25..4aa8a88 100644 (file)
@@ -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);