From patchwork Tue Jun 16 10:54:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 4041 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AB0A360103 for ; Tue, 16 Jun 2020 12:54:48 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="IuHc+Qg8"; dkim-atps=neutral Received: from jade.flets-east.jp (unknown [IPv6:2400:4051:61:600:2807:bdfa:f6a:8e53]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 38CBFF9; Tue, 16 Jun 2020 12:54:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1592304888; bh=csO003quMkKrRQuDv2njtRlhXleo+4XGIjTjVUkd3Eo=; h=From:To:Cc:Subject:Date:From; b=IuHc+Qg8EyGIYPTrNjoL4Sz5oTOEWe4aasShTRCWcWcHKmcmJJBlPSmI2DDblW+HK Tf7apnPuDN5QENt2P1h+TNc7wMzJ99lmhqFKRyPRANgC7ttIclTbj/cxGXY6kVgHU6 6W1xq3m5MG6vXaneSj5tsH2Ln4GGysr+0MZeBhg4= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Tue, 16 Jun 2020 19:54:34 +0900 Message-Id: <20200616105434.57451-1-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] v4l2: v4l2_camera_proxy, v4l2_camera: Check return values of read/write X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Jun 2020 10:54:48 -0000 The return value of the write to the eventfd (to signal POLLIN) from V4L2Camera and the read from the eventfd (to clear POLLIN) from V4L2CameraProxy was not ignored. Check the return value, and print an error message. Reported-by: Coverity CID=290743 Reported-by: Coverity CID=290744 Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- src/v4l2/v4l2_camera.cpp | 4 +++- src/v4l2/v4l2_camera_proxy.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/v4l2/v4l2_camera.cpp b/src/v4l2/v4l2_camera.cpp index 3c36932..9a1ebc8 100644 --- a/src/v4l2/v4l2_camera.cpp +++ b/src/v4l2/v4l2_camera.cpp @@ -91,7 +91,9 @@ void V4L2Camera::requestComplete(Request *request) bufferLock_.unlock(); uint64_t data = 1; - ::write(efd_, &data, sizeof(data)); + int ret = ::write(efd_, &data, sizeof(data)); + if (ret != sizeof(data)) + LOG(V4L2Compat, Error) << "Failed to signal eventfd POLLIN"; bufferSema_.release(); } diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp index 308a8ab..17477ab 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -454,7 +454,9 @@ int V4L2CameraProxy::vidioc_dqbuf(struct v4l2_buffer *arg) currentBuf_ = (currentBuf_ + 1) % bufferCount_; uint64_t data; - ::read(efd_, &data, sizeof(data)); + ret = ::read(efd_, &data, sizeof(data)); + if (ret != sizeof(data)) + LOG(V4L2Compat, Error) << "Failed to clear eventfd POLLIN"; return 0; }