mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2026-06-07 02:58:22 +02:00
os: check ospoll allocation failures
ospoll_create() initializes backend-specific state immediately after allocating the ospoll structure. Check the allocation result for each backend before dereferencing it and return NULL on failure. Signed-off-by: Mikhail Dmitrichenko <m.dmitrichenko222@gmail.com> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2217>
This commit is contained in:
parent
872ece04f9
commit
08e65ce8ae
1 changed files with 6 additions and 0 deletions
|
|
@ -207,6 +207,8 @@ ospoll_create(void)
|
|||
{
|
||||
#if POLLSET
|
||||
struct ospoll *ospoll = calloc(1, sizeof (struct ospoll));
|
||||
if (!ospoll)
|
||||
return NULL;
|
||||
|
||||
ospoll->ps = pollset_create(-1);
|
||||
if (ospoll->ps < 0) {
|
||||
|
|
@ -217,6 +219,8 @@ ospoll_create(void)
|
|||
#endif
|
||||
#if PORT
|
||||
struct ospoll *ospoll = calloc(1, sizeof (struct ospoll));
|
||||
if (!ospoll)
|
||||
return NULL;
|
||||
|
||||
ospoll->epoll_fd = port_create();
|
||||
if (ospoll->epoll_fd < 0) {
|
||||
|
|
@ -228,6 +232,8 @@ ospoll_create(void)
|
|||
#endif
|
||||
#if EPOLL
|
||||
struct ospoll *ospoll = calloc(1, sizeof (struct ospoll));
|
||||
if (!ospoll)
|
||||
return NULL;
|
||||
|
||||
ospoll->epoll_fd = epoll_create1(EPOLL_CLOEXEC);
|
||||
if (ospoll->epoll_fd < 0) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue