From afb24c6612c1e7923ac94855b07a2d1003d4f42f Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Mon, 22 Apr 2024 13:29:13 +0200 Subject: [PATCH] panfrost: do not deref potentially null pointer We need to check for failure to import *before* we dereference here. Fixes: f94889d0797 ("panfrost: Make pan_texture.{c,h} panfrost_bo agnostic") CID: 1587376 Reviewed-by: Boris Brezillon Part-of: (cherry picked from commit 8deaf37047c2295c0454e0668e0008edb21dd40e) --- .pick_status.json | 2 +- src/gallium/drivers/panfrost/pan_resource.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 132fbebfceb..114e1d6fa9f 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1014,7 +1014,7 @@ "description": "panfrost: do not deref potentially null pointer", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "f94889d0797f6dc66b7875e68ae7d44c0f018131", "notes": null diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index e43c23da76d..d90baa92535 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -725,13 +725,14 @@ panfrost_resource_create_with_modifier(struct pipe_screen *screen, } assert(handle.type == WINSYS_HANDLE_TYPE_FD); so->bo = panfrost_bo_import(dev, handle.handle); - so->image.data.base = so->bo->ptr.gpu; close(handle.handle); if (!so->bo) { free(so); return NULL; } + + so->image.data.base = so->bo->ptr.gpu; } else { /* We create a BO immediately but don't bother mapping, since we don't * care to map e.g. FBOs which the CPU probably won't touch */