aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGil Pitney <gil.pitney@linaro.org>2015-06-02 22:36:28 +0000
committerGil Pitney <gil.pitney@linaro.org>2015-06-02 22:36:28 +0000
commite6367bae140986ea1ce0c4d9493ff36343e7bc30 (patch)
tree32987c4cab2973eae14df15bf68a4578c195a639
parentaec5b6f387c8cb206ad4d19255a13a7242149ef6 (diff)
Fix possible CPUDevice object mem leak in clCreateSubDevices
Devices were previously being created during enumeration even when client was not asking for the devices. This is fixed. Signed-off-by: Gil Pitney <gil.pitney@linaro.org>
-rw-r--r--src/core/cpu/device.cpp8
-rw-r--r--src/core/cpu/device.h2
2 files changed, 6 insertions, 4 deletions
diff --git a/src/core/cpu/device.cpp b/src/core/cpu/device.cpp
index a8d6aaf..254bcbd 100644
--- a/src/core/cpu/device.cpp
+++ b/src/core/cpu/device.cpp
@@ -372,9 +372,11 @@ cl_int CPUDevice::createSubDevices(
if (partition_size) {
// Create num_new_devices SubDevices:
Coal::CPUDevice * new_device;
- for (int i = 0; i < num_new_devices; i++) {
- new_device = new CPUDevice(this, partition_size);
- if (out_devices) out_devices[i] = (cl_device_id)new_device;
+ if (out_devices) {
+ for (int i = 0; i < num_new_devices; i++) {
+ new_device = new CPUDevice(this, partition_size);
+ out_devices[i] = (cl_device_id)new_device;
+ }
}
if (num_devices_ret) *num_devices_ret = num_new_devices;
}
diff --git a/src/core/cpu/device.h b/src/core/cpu/device.h
index b2f5711..a730d08 100644
--- a/src/core/cpu/device.h
+++ b/src/core/cpu/device.h
@@ -103,7 +103,7 @@ class CPUDevice : public DeviceInterface
std::string builtinsHeader(void) const { return "cpu.h"; }
private:
- unsigned int p_cores, p_num_events, p_compute_units;
+ unsigned int p_cores, p_num_events;
float p_cpu_mhz;
std::string p_device_name;
pthread_t *p_workers;