From patchwork Fri Apr 2 04:03:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11825 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 71485C0DA3 for ; Fri, 2 Apr 2021 04:03:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CE48E68783; Fri, 2 Apr 2021 06:03:49 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="irUXUay3"; dkim-atps=neutral Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B7DB36877C for ; Fri, 2 Apr 2021 06:03:47 +0200 (CEST) Received: by mail-pg1-x531.google.com with SMTP id h25so2874073pgm.3 for ; Thu, 01 Apr 2021 21:03:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+KJdgHJvgzMEZGQYBG6MDGTXmmtctg3J9xAj8r9oFj8=; b=irUXUay3qB8D1B2cpEl/VXps4/dn+lu8qoAo1RcObOsrboz2fxj7ftpw3Yzohpe42t FDy+fA6yzEwnGE1D5VkEiP1AFnJA8uIGj0D48GoN2wG2e68ZuV5/XrqgHHNkphvLXDqK kziFNw0Y/FbHZwFttqdvMEGnbk3kx1giy7G78= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+KJdgHJvgzMEZGQYBG6MDGTXmmtctg3J9xAj8r9oFj8=; b=lzyRxsh/7pwdcCMqiOKn8drLoFTOsmDu7bN+iA45t/qxUJxWnTzh2xaDYitZX6xjBe x0oiuAlKE/61fXRaoZksns2Y4MqUiDnTdkOwYBqdG4hZgyMEUoOG8+EfVXJthwdEf4YS EBX0Jk3H1N1xSq2qBom7Ae3Ux6MGLkreAUJTOdyzZXe1sRkqTdZ5DFmKoAFukEwwBN3/ cgwpniPijatopfXUBSZkfWW5SphGPkiRQiZkpIrTtdNK72igYvnR92SZ8sWAz+GRgFGF nj7vlZmNzKkVMXaAOa70QOo4rykPAe852kJjyE2SYGY1YWogd6MdRTIwGhlgpd0i6M8H HXFg== X-Gm-Message-State: AOAM533vttCtzENwK76s076sG3+101YV4/o7mAsRU4tz4GCb/14MeRt0 neTyQw1ZBYl1vHsbz6ODOfomA+ETFqccKA== X-Google-Smtp-Source: ABdhPJzrj04EmSx+ige30Viv30n8bU5YB0GfhdbNGq3bttA/spaU/CuG/sDYeyQ5EL05tlF4pgufig== X-Received: by 2002:a62:6202:0:b029:208:f11c:2143 with SMTP id w2-20020a6262020000b0290208f11c2143mr10584488pfb.32.1617336226132; Thu, 01 Apr 2021 21:03:46 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:908:1da:b07c:32bc]) by smtp.gmail.com with ESMTPSA id 38sm6517715pgk.30.2021.04.01.21.03.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Apr 2021 21:03:45 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Fri, 2 Apr 2021 13:03:40 +0900 Message-Id: <20210402040340.1364749-1-hiroh@chromium.org> X-Mailer: git-send-email 2.31.0.208.g409f899ff0-goog MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2] android: CameraBuffer: Mark as invalid if cros::CameraBufferManager::Register() fails 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" cros::CameraBufferManager::Register() fails if a buffer handle is invalid. We should mark CameraBuffer as invalid on the failure of Register(). Signed-off-by: Hirokazu Honda Reviewed-by: Laurent Pinchart --- src/android/mm/cros_camera_buffer.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/android/mm/cros_camera_buffer.cpp b/src/android/mm/cros_camera_buffer.cpp index 7df4f47c..5f98ee44 100644 --- a/src/android/mm/cros_camera_buffer.cpp +++ b/src/android/mm/cros_camera_buffer.cpp @@ -53,12 +53,16 @@ CameraBuffer::Private::Private(CameraBuffer *cameraBuffer, { bufferManager_ = cros::CameraBufferManager::GetInstance(); - bufferManager_->Register(camera3Buffer); + int ret = bufferManager_->Register(camera3Buffer); + if (ret) { + LOG(HAL, Error) << "Failed registering a buffer: " << ret; + return; + } numPlanes_ = bufferManager_->GetNumPlanes(camera3Buffer); switch (numPlanes_) { case 1: { - int ret = bufferManager_->Lock(handle_, 0, 0, 0, 0, 0, &mem.addr); + ret = bufferManager_->Lock(handle_, 0, 0, 0, 0, 0, &mem.addr); if (ret) { LOG(HAL, Error) << "Single plane buffer mapping failed"; return; @@ -67,8 +71,8 @@ CameraBuffer::Private::Private(CameraBuffer *cameraBuffer, } case 2: case 3: { - int ret = bufferManager_->LockYCbCr(handle_, 0, 0, 0, 0, 0, - &mem.ycbcr); + ret = bufferManager_->LockYCbCr(handle_, 0, 0, 0, 0, 0, + &mem.ycbcr); if (ret) { LOG(HAL, Error) << "YCbCr buffer mapping failed"; return;