x86/mcheck: Explicit cleanup on failure in mce_amd
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Thu, 10 Nov 2016 17:44:42 +0000 (18:44 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 16 Nov 2016 08:34:17 +0000 (09:34 +0100)
If the ONLINE callback fails, the driver does not any clean up right
away instead it waits to get to the DEAD stage to do it. Yes, it waits.
Since we don't pass the error code back to the caller, no one knows.

Do the clean up right away so it does not look like a leak.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Borislav Petkov <bp@alien8.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: rt@linutronix.de
Cc: linux-edac@vger.kernel.org
Link: http://lkml.kernel.org/r/20161110174447.11848-3-bigeasy@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
arch/x86/kernel/cpu/mcheck/mce_amd.c

index 75a3e3eab81e71e5aa37b3505e5ff46f53887144..55cd018bc1ae91b31ce6a6a693b18eb47047147d 100644 (file)
@@ -1087,6 +1087,7 @@ static void threshold_remove_device(unsigned int cpu)
                threshold_remove_bank(cpu, bank);
        }
        kfree(per_cpu(threshold_banks, cpu));
+       per_cpu(threshold_banks, cpu) = NULL;
 }
 
 /* create dir/files for all valid threshold banks */
@@ -1108,9 +1109,11 @@ static int threshold_create_device(unsigned int cpu)
                        continue;
                err = threshold_create_bank(cpu, bank);
                if (err)
-                       return err;
+                       goto err;
        }
-
+       return err;
+err:
+       threshold_remove_device(cpu);
        return err;
 }