[Mesa-dev] [PATCH] clover: Check the return value of pipe_loader_probe() when probing for devices

Samuel Pitoiset samuel.pitoiset at gmail.com
Sun Nov 29 08:14:25 PST 2015


This patch fixes the issue for me (eg. 
https://bugs.freedesktop.org/show_bug.cgi?id=93091#c8).

Thanks Tom.

Tested-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>

On 11/28/2015 03:52 AM, Tom Stellard wrote:
> 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-stable at 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 &) {
>


More information about the mesa-dev mailing list