When probing for devices, clover will call pipe_loader_probe() twice. The first time to retrieve the number of devices, and then second time to retrieve the device structures.
We currently assume that the return value of both calls will be the same, but this will not be the case if a device happens to disappear between the two calls. This patch removes this assumption and checks the return value of the second pipe_loader_probe() call to ensure it does not try to initialize devices that no longer exits. CC: <mesa-sta...@lists.freedesktop.org> --- src/gallium/state_trackers/clover/core/platform.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gallium/state_trackers/clover/core/platform.cpp b/src/gallium/state_trackers/clover/core/platform.cpp index 328b71c..689d692 100644 --- a/src/gallium/state_trackers/clover/core/platform.cpp +++ b/src/gallium/state_trackers/clover/core/platform.cpp @@ -28,9 +28,10 @@ platform::platform() : adaptor_range(evals(), devs) { int n = pipe_loader_probe(NULL, 0); std::vector<pipe_loader_device *> ldevs(n); - pipe_loader_probe(&ldevs.front(), n); + n = pipe_loader_probe(&ldevs.front(), n); - for (pipe_loader_device *ldev : ldevs) { + for (int i = 0; i < n; ++i) { + pipe_loader_device *ldev = ldevs[i]; try { devs.push_back(create<device>(*this, ldev)); } catch (error &) { -- 2.0.4 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev