s390/perf: Return error when debug_register fails
authorThomas Richter <tmricht@linux.ibm.com>
Mon, 15 Oct 2018 13:39:29 +0000 (14:39 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 1 Dec 2019 08:13:43 +0000 (09:13 +0100)
[ Upstream commit ec0c0bb489727de0d4dca6a00be6970ab8a3b30a ]

Return an error when the function debug_register() fails allocating
the debug handle.
Also remove the registered debug handle when the initialization fails
later on.

Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/s390/kernel/perf_cpum_sf.c

index d99155793c26ec4d78f078e7b2c0a766a23740f1..2e2fd9535f8658716f4f5aad2f41fc7e3bafdbf1 100644 (file)
@@ -1610,14 +1610,17 @@ static int __init init_cpum_sampling_pmu(void)
        }
 
        sfdbg = debug_register(KMSG_COMPONENT, 2, 1, 80);
-       if (!sfdbg)
+       if (!sfdbg) {
                pr_err("Registering for s390dbf failed\n");
+               return -ENOMEM;
+       }
        debug_register_view(sfdbg, &debug_sprintf_view);
 
        err = register_external_irq(EXT_IRQ_MEASURE_ALERT,
                                    cpumf_measurement_alert);
        if (err) {
                pr_cpumsf_err(RS_INIT_FAILURE_ALRT);
+               debug_unregister(sfdbg);
                goto out;
        }
 
@@ -1626,6 +1629,7 @@ static int __init init_cpum_sampling_pmu(void)
                pr_cpumsf_err(RS_INIT_FAILURE_PERF);
                unregister_external_irq(EXT_IRQ_MEASURE_ALERT,
                                        cpumf_measurement_alert);
+               debug_unregister(sfdbg);
                goto out;
        }