From patchwork Thu Mar 17 13:17:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 15469 X-Patchwork-Delegate: kieran.bingham@ideasonboard.com 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 67648BF415 for ; Thu, 17 Mar 2022 13:17:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C7CF5604E9; Thu, 17 Mar 2022 14:17:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1647523051; bh=AAoAudW3c74ZeOc34gLEe8dgQFy+Rxh3+/Hjofl6Crs=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=wAMaFHJyQGWPPzO8VqtLHl6m0ch330c4YGbG4DKmmFQ1K+9Pwva03aI3J7GLKE9Tn gYdbmTdK/dzXcEpx5H3mtwX7MLcD+aoZxR1FWS6bMaB7u1Yub8nRzd666wiH9vDX20 r++Mx/sLJK4vd38MwIDabdT3DQJk6EyzVcInk58R+o4QzNDQM66P0CtFotnSsBLmYA N5etZaQHNdr+2y/mvgH+DN1ijE4if6XjX3svosX+fPc4fIy20CSGcIbEctb8kpipDf gcz9jORa2jNwRKrDblhJrsXAu+dbR+jH1xsQQFogyNr2hTBeGNg9F8gd8l6urGz1A/ owWgqHpTmKJIQ== 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 3FC9E601F8 for ; Thu, 17 Mar 2022 14:17:30 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ujWYogm1"; dkim-atps=neutral Received: from Monstersaurus.ksquared.org.uk.beta.tailscale.net (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BF7FC493; Thu, 17 Mar 2022 14:17:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1647523049; bh=AAoAudW3c74ZeOc34gLEe8dgQFy+Rxh3+/Hjofl6Crs=; h=From:To:Cc:Subject:Date:From; b=ujWYogm1ZfSTfoFwCwQD4p/AY1zeoWr9ltXMTsP9Jq2zRcd+NUT4+vy8WuCX8wrdB DlmRm46HCDJr92gja1RK+rINTb/2BIOoB30rUnueFNAnqY1GGcKTDO3YouN5gtjCD6 naHPTBu3BvtQDIyr8LpJlqu03e71u6ae1duBWEaU= To: libcamera devel Date: Thu, 17 Mar 2022 13:17:26 +0000 Message-Id: <20220317131726.1483971-1-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] libcamera: camera: Ensure requests belong to the camera 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" Requests are created by a Camera, and can only be queued to that specific Camera. Enforce this during the public API to prevent mis-use by incorrect applications. Signed-off-by: Kieran Bingham Reviewed-by: Umang Jain Reviewed-by: Laurent Pinchart --- src/libcamera/camera.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index bb856d606f4a..dd6552e83eee 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -23,6 +23,7 @@ #include "libcamera/internal/camera_controls.h" #include "libcamera/internal/formats.h" #include "libcamera/internal/pipeline_handler.h" +#include "libcamera/internal/request.h" /** * \file libcamera/camera.h @@ -1119,6 +1120,12 @@ int Camera::queueRequest(Request *request) if (ret < 0) return ret; + /* Requests can only be queued to the camera that created them.*/ + if (request->_d()->camera() != this) { + LOG(Camera, Error) << "Request was not created by this camera"; + return -EINVAL; + } + /* * The camera state may change until the end of the function. No locking * is however needed as PipelineHandler::queueRequest() will handle