]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
s390/pai_crypto: emit error on too many counters
authorThomas Richter <tmricht@linux.ibm.com>
Thu, 18 Jan 2024 12:24:45 +0000 (13:24 +0100)
committerHeiko Carstens <hca@linux.ibm.com>
Fri, 9 Feb 2024 12:58:13 +0000 (13:58 +0100)
When the device driver is initialized, it checks the number of
possible counters. Should this number be too high, emit an error
and return.

Reported-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Acked-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
arch/s390/kernel/perf_pai_crypto.c

index 522a5ea0a9f49c68b52b4426533f23f2c314baa4..69639ff1c5e0326757215b1a2fad52f8480ba819 100644 (file)
@@ -742,8 +742,10 @@ static int __init paicrypt_init(void)
        paicrypt_cnt = ib.num_cc;
        if (paicrypt_cnt == 0)
                return 0;
-       if (paicrypt_cnt >= PAI_CRYPTO_MAXCTR)
-               paicrypt_cnt = PAI_CRYPTO_MAXCTR - 1;
+       if (paicrypt_cnt >= PAI_CRYPTO_MAXCTR) {
+               pr_err("Too many PMU pai_crypto counters %d\n", paicrypt_cnt);
+               return -1;
+       }
 
        rc = attr_event_init();         /* Export known PAI crypto events */
        if (rc) {