From patchwork Mon Aug 30 19:01:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13569 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 6BAA1BD87D for ; Mon, 30 Aug 2021 19:01:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 922E26916A; Mon, 30 Aug 2021 21:01:53 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="L0YUYErQ"; dkim-atps=neutral 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 B7B6B60258 for ; Mon, 30 Aug 2021 21:01:51 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1C0615A7; Mon, 30 Aug 2021 21:01:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1630350111; bh=qyDBwf1oE3W8j6UYLySW7MNBX1hHUrcPNZotGhWBsmc=; h=From:To:Cc:Subject:Date:From; b=L0YUYErQ28kIdWYCDVkY+JY34H81TbSRjqpOA6a1vV2pBG3/palHJqwRSIOtfjtT1 pE8bAeoNBj5thmFczX11Jcl4LA+Fg6QolstvJNtMkKT4M5GLXG3RR5MUBUfTynaXWA XSm7AyyfVGCpLixHZHm6udnwUCnsLdrKGJFgyY4Y= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 30 Aug 2021 22:01:33 +0300 Message-Id: <20210830190133.27155-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] android: generic_camera_buffer: Fix bufferLength_ initialization 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The bufferLength_ member variabled is checked to have a positive value before being used, to catch usage before the variable is set. The variable is initialized to zero at construction time, which renders the checks useless. Fix this by initializing the variable to -1 at construction time. Fixes: c5e2ed7806be ("android: camera_buffer: Map buffer in the first plane() call") Signed-off-by: Laurent Pinchart Reviewed-by: Hirokazu Honda Reviewed-by: Jacopo Mondi --- I've accidentally applied v3 of "android: camera_buffer: Map buffer in the first plane() call" before Hiro mentioned a v4 was needed. Sorry about that. --- src/android/mm/generic_camera_buffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/android/mm/generic_camera_buffer.cpp b/src/android/mm/generic_camera_buffer.cpp index a41ae2c96023..22efc4d4b13a 100644 --- a/src/android/mm/generic_camera_buffer.cpp +++ b/src/android/mm/generic_camera_buffer.cpp @@ -60,7 +60,7 @@ CameraBuffer::Private::Private([[maybe_unused]] CameraBuffer *cameraBuffer, buffer_handle_t camera3Buffer, libcamera::PixelFormat pixelFormat, const libcamera::Size &size, int flags) - : fd_(-1), flags_(flags), bufferLength_(0), mapped_(false) + : fd_(-1), flags_(flags), bufferLength_(-1), mapped_(false) { error_ = 0;