Skip to content

Commit

Permalink
fix possible crash 3
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxerski committed Jul 20, 2024
1 parent 78d11c4 commit aa1ebc5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
15 changes: 8 additions & 7 deletions src/protocols/LinuxDMABUF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@ CLinuxDMABufV1Protocol::CLinuxDMABufV1Protocol(const wl_interface* iface, const
auto dev = devIDFromFD(rendererFD);

if (!dev.has_value()) {
LOGM(ERR, "failed to get drm dev");
PROTO::linuxDma.reset();
protoLog(ERR, "failed to get drm dev, disabling linux dmabuf");
removeGlobal();
return;
}

Expand Down Expand Up @@ -477,8 +477,8 @@ CLinuxDMABufV1Protocol::CLinuxDMABufV1Protocol(const wl_interface* iface, const

drmDevice* device = nullptr;
if (drmGetDeviceFromDevId(mainDevice, 0, &device) != 0) {
LOGM(ERR, "failed to get drm dev");
PROTO::linuxDma.reset();
protoLog(ERR, "failed to get drm dev, disabling linux dmabuf");
removeGlobal();
return;
}

Expand All @@ -487,13 +487,14 @@ CLinuxDMABufV1Protocol::CLinuxDMABufV1Protocol(const wl_interface* iface, const
mainDeviceFD = open(name, O_RDWR | O_CLOEXEC);
drmFreeDevice(&device);
if (mainDeviceFD < 0) {
LOGM(ERR, "failed to open drm dev");
PROTO::linuxDma.reset();
protoLog(ERR, "failed to open drm dev, disabling linux dmabuf");
removeGlobal();
return;
}
} else {
LOGM(ERR, "DRM device {} has no render node!!", device->nodes[DRM_NODE_PRIMARY] ? device->nodes[DRM_NODE_PRIMARY] : "null");
protoLog(ERR, "DRM device {} has no render node, disabling linux dmabuf", device->nodes[DRM_NODE_PRIMARY] ? device->nodes[DRM_NODE_PRIMARY] : "null");
drmFreeDevice(&device);
removeGlobal();
}
});
}
Expand Down
8 changes: 4 additions & 4 deletions src/protocols/MesaDRM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ CMesaDRMProtocol::CMesaDRMProtocol(const wl_interface* iface, const int& ver, co
drmDevice* dev = nullptr;
int drmFD = g_pCompositor->m_iDRMFD;
if (drmGetDevice2(drmFD, 0, &dev) != 0) {
LOGM(ERR, "Failed to get device");
PROTO::mesaDRM.reset();
protoLog(ERR, "Failed to get device, disabling MesaDRM");
removeGlobal();
return;
}

Expand All @@ -126,13 +126,13 @@ CMesaDRMProtocol::CMesaDRMProtocol(const wl_interface* iface, const int& ver, co
ASSERT(dev->available_nodes & (1 << DRM_NODE_PRIMARY));

if (!dev->nodes[DRM_NODE_PRIMARY]) {
LOGM(ERR, "No DRM render node available, both render and primary are null, disabling MesaDRM");
protoLog(ERR, "No DRM render node available, both render and primary are null, disabling MesaDRM");
drmFreeDevice(&dev);
removeGlobal();
return;
}

LOGM(WARN, "No DRM render node, falling back to primary {}", dev->nodes[DRM_NODE_PRIMARY]);
protoLog(WARN, "No DRM render node, falling back to primary {}", dev->nodes[DRM_NODE_PRIMARY]);
nodeName = dev->nodes[DRM_NODE_PRIMARY];
}
drmFreeDevice(&dev);
Expand Down

0 comments on commit aa1ebc5

Please sign in to comment.