Module: Mesa
Branch: main
Commit: 0541a57517f7b8b6a518b0cdb94d2be8f8243257
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0541a57517f7b8b6a518b0cdb94d2be8f8243257

Author: Corentin Noël <corentin.n...@collabora.com>
Date:   Mon Jan  8 12:22:54 2024 +0100

virgl: Assert build_id_note before dereferencing it

Fix defect reported by Coverity Scan.

Dereference null return value

If the function actually returns a null value, a null pointer dereference will 
occur.

CID: 1492763

Signed-off-by: Corentin Noël <corentin.n...@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26924>

---

 src/gallium/drivers/virgl/virgl_screen.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/virgl/virgl_screen.c 
b/src/gallium/drivers/virgl/virgl_screen.c
index 44f2a28ca56..e7985e7e072 100644
--- a/src/gallium/drivers/virgl/virgl_screen.c
+++ b/src/gallium/drivers/virgl/virgl_screen.c
@@ -1054,8 +1054,10 @@ static void virgl_disk_cache_create(struct virgl_screen 
*screen)
 {
    const struct build_id_note *note =
       build_id_find_nhdr_for_addr(virgl_disk_cache_create);
+   assert(note);
+
    unsigned build_id_len = build_id_length(note);
-   assert(note && build_id_len == 20); /* sha1 */
+   assert(build_id_len == 20); /* sha1 */
 
    const uint8_t *id_sha1 = build_id_data(note);
    assert(id_sha1);

Reply via email to