From patchwork Mon Jan 30 18:02:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 18225 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id DBC30C328C for ; Mon, 30 Jan 2023 18:02:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D5314625EA; Mon, 30 Jan 2023 19:02:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1675101770; bh=3if+N+QqMPI/yb8qphMcMG4atLJELfDyvREaFZdGC9A=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=cb/wKF4vu1bALQ8xWwa0e6fSDkXREpjqaUX+5JnfqXwqgSbP1ABIOIwic7E71yRed r5cZAjJHGs9IspoIDMBDO2pB3sgzHSMxPtD+DUBaa5aWG5TxC9gA/ATVIzazBnBbTO r05phQ/Xs0+HnRiz8QCyUbX1GUtlg1B7ZlWhXyTpMS9KkBzR1RDu8EiNQguXS8Tvhr eYeCuV4s7trd+ydMkLs0/Fvf7tQPsfEkV1LfNWgNbUsR3qIb2IeWyZvnD1uAjsJs6j YiHlH/gvSp0mtMWehnkGGYCDuXFRzt2cx9cYSaCeRLLaucXre+MWJ1KmLGTwsRWHpy HWlFK1ECa8s1A== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8B0A7625D8 for ; Mon, 30 Jan 2023 19:02:48 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="R0LNEK6q"; dkim-atps=neutral Received: from Monstersaurus.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1B09F8CC; Mon, 30 Jan 2023 19:02:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1675101768; bh=3if+N+QqMPI/yb8qphMcMG4atLJELfDyvREaFZdGC9A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R0LNEK6q3BATS8V0YROJyUjO5Mf5VFM9Do3IX8FtX8jY0pbAwcKF1BZ0C81AuUnVr cf6OB3q6Z80QJI1eQ5VkhVn09Vre/RJ8fZmL7qWQJcjosjPrd9SpJ6GPl9r6EMAynF 5dusCf+pIzcNSdl7RR7esaQxd9Ov3y3kypFgXUr0= To: libcamera devel Date: Mon, 30 Jan 2023 18:02:43 +0000 Message-Id: <20230130180244.2150205-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230130180244.2150205-1-kieran.bingham@ideasonboard.com> References: <20230130180244.2150205-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/2] libcamera: camera: Ensure queued requests are prepared 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-Patchwork-Original-From: Kieran Bingham via libcamera-devel From: Kieran Bingham Reply-To: Kieran Bingham Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Invalid, or not correctly reset requests can cause undefined behaviour in the pipeline handlers due to unexpected request state. If the status has not been reset to Request::RequestPending, it is either not new, or has not been correctly procesed through Request::reuse(). This can be caught early by validating the status of the request when it is queued to a camera. Reject invalid requests before processing them in the pipeline handlers. Signed-off-by: Kieran Bingham Reviewed-by: Jacopo Mondi Reviewed-by: Paul Elder --- src/libcamera/camera.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 0da167a7bc51..48bf19b28979 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -1126,6 +1126,11 @@ int Camera::queueRequest(Request *request) return -EXDEV; } + if (request->status() != Request::RequestPending) { + LOG(Camera, Error) << request->toString() << " is not prepared"; + return -EINVAL; + } + /* * The camera state may change until the end of the function. No locking * is however needed as PipelineHandler::queueRequest() will handle