i965/bufmgr: Handle NULL bufmgr in brw_bufmgr_get_for_fd

brw_bufmgr_create can return NULL, in which case we'd crash in
list_addtail.

Reported by Coverity/clang.

Fixes: 4094558e86 ("i965: share buffer managers across screens")
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7335>
(cherry picked from commit eb61f8959e)
This commit is contained in:
Michel Dänzer 2020-10-27 11:40:05 +01:00 committed by Dylan Baker
parent f06c466895
commit 436592d1f4
2 changed files with 3 additions and 2 deletions

View file

@ -5557,7 +5557,7 @@
"description": "i965/bufmgr: Handle NULL bufmgr in brw_bufmgr_get_for_fd",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"master_sha": null,
"because_sha": "4094558e8643a266dfc8da9bc073751a3736a2fb"
},

View file

@ -1947,7 +1947,8 @@ brw_bufmgr_get_for_fd(struct gen_device_info *devinfo, int fd, bool bo_reuse)
}
bufmgr = brw_bufmgr_create(devinfo, fd, bo_reuse);
list_addtail(&bufmgr->link, &global_bufmgr_list);
if (bufmgr)
list_addtail(&bufmgr->link, &global_bufmgr_list);
unlock:
mtx_unlock(&global_bufmgr_list_mutex);