panfrost: Don't leak NIR compute shaders
authorBoris Brezillon <boris.brezillon@collabora.com>
Thu, 30 Nov 2023 10:15:10 +0000 (11:15 +0100)
committerEric Engestrom <eric@engestrom.ch>
Fri, 8 Dec 2023 11:12:43 +0000 (11:12 +0000)
We never steal the NIR program or free it explicitly, and the state
tracker expects drivers to take ownership of the program object. Since
panfrost doesn't need to keep the original NIR shader around for
compute, let's just free it before returning.

Fixes: 40372bd720fe ("panfrost: Implement a disk cache")
Cc: stable
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26424>
(cherry picked from commit 692a4b18047a9549ec993c6bded598c5f0c06de0)

.pick_status.json
src/gallium/drivers/panfrost/pan_shader.c

index 6de6401..bd033e9 100644 (file)
         "description": "panfrost: Don't leak NIR compute shaders",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "40372bd720fe16186e9abc832bb452a3143d0e00",
         "notes": null
index 42bb2f7..546910f 100644 (file)
@@ -470,6 +470,7 @@ panfrost_create_compute_state(struct pipe_context *pctx,
    /* The NIR becomes invalid after this. For compute kernels, we never
     * need to access it again. Don't keep a dangling pointer around.
     */
+   ralloc_free((void *)so->nir);
    so->nir = NULL;
 
    return so;