Loading...
--- xnu/xnu-12377.101.15/iokit/Kernel/IOInterruptEventSource.cpp
+++ xnu/xnu-7195.141.2/iokit/Kernel/IOInterruptEventSource.cpp
@@ -84,15 +84,17 @@
{
bool res = true;
- if (inIntIndex < 0) {
- return false;
- }
-
if (!super::init(inOwner, (IOEventSourceAction) inAction)) {
return false;
}
- reserved = IOMallocType(ExpansionData);
+ reserved = IONew(ExpansionData, 1);
+
+ if (!reserved) {
+ return false;
+ }
+
+ bzero(reserved, sizeof(ExpansionData));
provider = inProvider;
producerCount = consumerCount = 0;
@@ -111,7 +113,17 @@
* We also avoid try to avoid interrupt accounting overhead if none of
* the statistics are enabled.
*/
- reserved->statistics = IOMallocType(IOInterruptAccountingData);
+ reserved->statistics = IONew(IOInterruptAccountingData, 1);
+
+ if (!reserved->statistics) {
+ /*
+ * We rely on the free() routine to clean up after us if init fails
+ * midway.
+ */
+ return false;
+ }
+
+ bzero(reserved->statistics, sizeof(IOInterruptAccountingData));
reserved->statistics->owner = this;
}
@@ -239,10 +251,10 @@
if (reserved) {
if (reserved->statistics) {
- IOFreeType(reserved->statistics, IOInterruptAccountingData);
- }
-
- IOFreeType(reserved, ExpansionData);
+ IODelete(reserved->statistics, IOInterruptAccountingData, 1);
+ }
+
+ IODelete(reserved, ExpansionData, 1);
}
super::free();
@@ -413,18 +425,18 @@
}
if (reserved->statistics) {
+ if (IA_GET_STATISTIC_ENABLED(kInterruptAccountingSecondLevelCountIndex)) {
+ IA_ADD_VALUE(&reserved->statistics->interruptStatistics[kInterruptAccountingSecondLevelCountIndex], 1);
+ }
+
+ if (IA_GET_STATISTIC_ENABLED(kInterruptAccountingSecondLevelCPUTimeIndex)) {
+ endCPUTime = thread_get_runtime_self();
+ IA_ADD_VALUE(&reserved->statistics->interruptStatistics[kInterruptAccountingSecondLevelCPUTimeIndex], endCPUTime - startCPUTime);
+ }
+
if (IA_GET_STATISTIC_ENABLED(kInterruptAccountingSecondLevelSystemTimeIndex)) {
endSystemTime = mach_absolute_time();
IA_ADD_VALUE(&reserved->statistics->interruptStatistics[kInterruptAccountingSecondLevelSystemTimeIndex], endSystemTime - startSystemTime);
- }
-
- if (IA_GET_STATISTIC_ENABLED(kInterruptAccountingSecondLevelCPUTimeIndex)) {
- endCPUTime = thread_get_runtime_self();
- IA_ADD_VALUE(&reserved->statistics->interruptStatistics[kInterruptAccountingSecondLevelCPUTimeIndex], endCPUTime - startCPUTime);
- }
-
- if (IA_GET_STATISTIC_ENABLED(kInterruptAccountingSecondLevelCountIndex)) {
- IA_ADD_VALUE(&reserved->statistics->interruptStatistics[kInterruptAccountingSecondLevelCountIndex], 1);
}
}