livepatch: Initialize shadow variables safely by a custom callback
[linux-2.6-block.git] / samples / livepatch / livepatch-shadow-fix2.c
index ff9948f0ec007b77ff54a60cd6d88203d399cbc3..d6c62844dc150613bd4e371041b6366c0a6bf0c8 100644 (file)
@@ -53,17 +53,15 @@ struct dummy {
 bool livepatch_fix2_dummy_check(struct dummy *d, unsigned long jiffies)
 {
        int *shadow_count;
-       int count;
 
        /*
         * Patch: handle in-flight dummy structures, if they do not
         * already have a SV_COUNTER shadow variable, then attach a
         * new one.
         */
-       count = 0;
        shadow_count = klp_shadow_get_or_alloc(d, SV_COUNTER,
-                                              &count, sizeof(count),
-                                              GFP_NOWAIT);
+                               sizeof(*shadow_count), GFP_NOWAIT,
+                               NULL, NULL);
        if (shadow_count)
                *shadow_count += 1;