mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 00:38:48 +02:00
drisw: Properly mark shmid as -1 when alloc fails
Cc: mesa-stable
(cherry picked from commit b93bf19d94)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40359>
This commit is contained in:
parent
681de5a641
commit
8d313e5d1c
2 changed files with 7 additions and 3 deletions
|
|
@ -2434,7 +2434,7 @@
|
|||
"description": "drisw: Properly mark shmid as -1 when alloc fails",
|
||||
"nominated": true,
|
||||
"nomination_type": 1,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": null,
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -108,15 +108,19 @@ alloc_shm(struct dri_sw_displaytarget *dri_sw_dt, unsigned size)
|
|||
|
||||
/* 0600 = user read+write */
|
||||
dri_sw_dt->shmid = shmget(IPC_PRIVATE, size, IPC_CREAT | 0600);
|
||||
if (dri_sw_dt->shmid < 0)
|
||||
if (dri_sw_dt->shmid < 0) {
|
||||
dri_sw_dt->shmid = -1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
addr = (char *) shmat(dri_sw_dt->shmid, NULL, 0);
|
||||
/* mark the segment immediately for deletion to avoid leaks */
|
||||
shmctl(dri_sw_dt->shmid, IPC_RMID, NULL);
|
||||
|
||||
if (addr == (char *) -1)
|
||||
if (addr == (char *) -1) {
|
||||
dri_sw_dt->shmid = -1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return addr;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue