Loading libs/ui/BufferHubBuffer.cpp +15 −17 Original line number Original line Diff line number Diff line Loading @@ -167,32 +167,30 @@ int BufferHubBuffer::initWithBufferTraits(const BufferTraits& bufferTraits) { return -EINVAL; return -EINVAL; } } int bufferId = bufferTraits.bufferInfo->data[2]; // Import fds. Dup fds because hidl_handle owns the fds. if (bufferId < 0) { unique_fd ashmemFd(fcntl(bufferTraits.bufferInfo->data[0], F_DUPFD_CLOEXEC, 0)); ALOGE("%s: Received an invalid (negative) id!", __FUNCTION__); mMetadata = BufferHubMetadata::Import(std::move(ashmemFd)); if (!mMetadata.IsValid()) { ALOGE("%s: Received an invalid metadata.", __FUNCTION__); return -EINVAL; return -EINVAL; } } uint32_t clientBitMask; mEventFd = BufferHubEventFd(fcntl(bufferTraits.bufferInfo->data[1], F_DUPFD_CLOEXEC, 0)); memcpy(&clientBitMask, &bufferTraits.bufferInfo->data[3], sizeof(clientBitMask)); if (!mEventFd.isValid()) { if (clientBitMask == 0U) { ALOGE("%s: Received ad invalid event fd.", __FUNCTION__); ALOGE("%s: Received a invalid client state mask!", __FUNCTION__); return -EINVAL; return -EINVAL; } } // Import fds. Dup fds because hidl_handle owns the fds. int bufferId = bufferTraits.bufferInfo->data[2]; const int eventFd = fcntl(bufferTraits.bufferInfo->data[1], F_DUPFD_CLOEXEC, 0); if (bufferId < 0) { if (eventFd < 0) { ALOGE("%s: Received an invalid (negative) id.", __FUNCTION__); ALOGE("%s: Received a invalid event fd!", __FUNCTION__); return -EINVAL; return -EINVAL; } } mEventFd = BufferHubEventFd(eventFd); unique_fd ashmemFd(fcntl(bufferTraits.bufferInfo->data[0], F_DUPFD_CLOEXEC, 0)); mMetadata = BufferHubMetadata::Import(std::move(ashmemFd)); if (!mMetadata.IsValid()) { uint32_t clientBitMask; ALOGE("%s: invalid metadata.", __FUNCTION__); memcpy(&clientBitMask, &bufferTraits.bufferInfo->data[3], sizeof(clientBitMask)); if (clientBitMask == 0U) { ALOGE("%s: Received an invalid client state mask.", __FUNCTION__); return -EINVAL; return -EINVAL; } } Loading Loading
libs/ui/BufferHubBuffer.cpp +15 −17 Original line number Original line Diff line number Diff line Loading @@ -167,32 +167,30 @@ int BufferHubBuffer::initWithBufferTraits(const BufferTraits& bufferTraits) { return -EINVAL; return -EINVAL; } } int bufferId = bufferTraits.bufferInfo->data[2]; // Import fds. Dup fds because hidl_handle owns the fds. if (bufferId < 0) { unique_fd ashmemFd(fcntl(bufferTraits.bufferInfo->data[0], F_DUPFD_CLOEXEC, 0)); ALOGE("%s: Received an invalid (negative) id!", __FUNCTION__); mMetadata = BufferHubMetadata::Import(std::move(ashmemFd)); if (!mMetadata.IsValid()) { ALOGE("%s: Received an invalid metadata.", __FUNCTION__); return -EINVAL; return -EINVAL; } } uint32_t clientBitMask; mEventFd = BufferHubEventFd(fcntl(bufferTraits.bufferInfo->data[1], F_DUPFD_CLOEXEC, 0)); memcpy(&clientBitMask, &bufferTraits.bufferInfo->data[3], sizeof(clientBitMask)); if (!mEventFd.isValid()) { if (clientBitMask == 0U) { ALOGE("%s: Received ad invalid event fd.", __FUNCTION__); ALOGE("%s: Received a invalid client state mask!", __FUNCTION__); return -EINVAL; return -EINVAL; } } // Import fds. Dup fds because hidl_handle owns the fds. int bufferId = bufferTraits.bufferInfo->data[2]; const int eventFd = fcntl(bufferTraits.bufferInfo->data[1], F_DUPFD_CLOEXEC, 0); if (bufferId < 0) { if (eventFd < 0) { ALOGE("%s: Received an invalid (negative) id.", __FUNCTION__); ALOGE("%s: Received a invalid event fd!", __FUNCTION__); return -EINVAL; return -EINVAL; } } mEventFd = BufferHubEventFd(eventFd); unique_fd ashmemFd(fcntl(bufferTraits.bufferInfo->data[0], F_DUPFD_CLOEXEC, 0)); mMetadata = BufferHubMetadata::Import(std::move(ashmemFd)); if (!mMetadata.IsValid()) { uint32_t clientBitMask; ALOGE("%s: invalid metadata.", __FUNCTION__); memcpy(&clientBitMask, &bufferTraits.bufferInfo->data[3], sizeof(clientBitMask)); if (clientBitMask == 0U) { ALOGE("%s: Received an invalid client state mask.", __FUNCTION__); return -EINVAL; return -EINVAL; } } Loading