Skip to content

Commit 38098ed

Browse files
committed
s390/pai: fix attr_event_free upper limit for pai device drivers
jira LE-4018 Rebuild_History Non-Buildable kernel-5.14.0-570.37.1.el9_6 commit-author Thomas Richter <tmricht@linux.ibm.com> commit 225d09d When the device drivers are initialized, a sysfs directory is created. This contains many attributes which are allocated with kzalloc(). Should it fail, the memory for the attributes already created is freed in attr_event_free(). Its second parameter is number of attribute elements to delete. This parameter is off by one. When i. e. the 10th attribute fails to get created, attributes numbered 0 to 9 should be deleted. Currently only attributes numbered 0 to 8 are deleted. Fixes: 39d6233 ("s390/pai: add support for cryptography counters") 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> (cherry picked from commit 225d09d) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent d87cfa2 commit 38098ed

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

arch/s390/kernel/perf_pai_crypto.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ static int __init attr_event_init(void)
661661
for (i = 0; i < ARRAY_SIZE(paicrypt_ctrnames); i++) {
662662
ret = attr_event_init_one(attrs, i);
663663
if (ret) {
664-
attr_event_free(attrs, i - 1);
664+
attr_event_free(attrs, i);
665665
return ret;
666666
}
667667
}

arch/s390/kernel/perf_pai_ext.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ static int __init attr_event_init(void)
615615
for (i = 0; i < ARRAY_SIZE(paiext_ctrnames); i++) {
616616
ret = attr_event_init_one(attrs, i);
617617
if (ret) {
618-
attr_event_free(attrs, i - 1);
618+
attr_event_free(attrs, i);
619619
return ret;
620620
}
621621
}

0 commit comments

Comments
 (0)