From patchwork Fri May 15 12:42:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 3795 Return-Path: Received: from o1.f.az.sendgrid.net (o1.f.az.sendgrid.net [208.117.55.132]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0471860E04 for ; Fri, 15 May 2020 14:42:53 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=uajain.com header.i=@uajain.com header.b="eO84GZUU"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uajain.com; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type; s=s1; bh=nwEIAkapDHGcHhUqs9QsOYZYpbdReQVrJEj7JvJUIhQ=; b=eO84GZUUUx+BJofUTPUDgpix6bxrwwKX9/sOaAWB5lwwYvyxJ7AelY2ffLkQ2p13lky+ 4ueb43BmbFaJM26qZWs+2yKQBTvrXkooGemoZ6TE4EbHAuFnOmYbWjqfT3qVEe63gKVgtK 80sOE+YNMlAba4G5KlJ17dFE+blcYFW8s= Received: by filterdrecv-p3iad2-8ddf98858-7qsdm with SMTP id filterdrecv-p3iad2-8ddf98858-7qsdm-19-5EBE8E4C-32 2020-05-15 12:42:52.653305372 +0000 UTC m=+4361727.335562953 Received: from mail.uajain.com (unknown) by ismtpd0007p1maa1.sendgrid.net (SG) with ESMTP id P5V8PnQwRdWqfWPesnwfjg Fri, 15 May 2020 12:42:52.051 +0000 (UTC) From: Umang Jain Date: Fri, 15 May 2020 12:42:52 +0000 (UTC) Message-Id: <20200515124245.18040-2-email@uajain.com> In-Reply-To: <20200515124245.18040-1-email@uajain.com> References: <20200515124245.18040-1-email@uajain.com> Mime-Version: 1.0 X-SG-EID: 1Q40EQ7YGir8a9gjSIAdTjhngY657NMk9ckeo4dbHZDiOpywc/L3L9rFqlwE4KPcYDswUgqLHty1lirORaEntVnOx/r7D4hv5S0oXe9vaj0hrpQTq3hRAmZeRvRAd4sctXteVeh8mmJPDovpQNo1MOQ9n1stXIdPkAQ+yhmSbZsuw2DGXM57HKiJ7Gh6Rh9dN71auyHh3JuIzPDLFwZZ1v41Yjatwylor5sLzLHpuHCcAB/qI1exfztX8MoFxxX52AEuLFXE/lnvn2b1Sqd1og== To: libcamera-devel Subject: [libcamera-devel] [PATCH v2 1/4] test: ipc: unixsocket: Close open fds on error paths 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: Fri, 15 May 2020 12:42:54 -0000 Pointed out by Coverity DefectId=279099 Signed-off-by: Umang Jain Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- test/ipc/unixsocket.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/ipc/unixsocket.cpp b/test/ipc/unixsocket.cpp index f53042b..5348f35 100644 --- a/test/ipc/unixsocket.cpp +++ b/test/ipc/unixsocket.cpp @@ -145,6 +145,7 @@ private: if (num < 0) { cerr << "Read failed" << endl; + close(outfd); stop(-EIO); return; } else if (!num) @@ -152,6 +153,7 @@ private: if (write(outfd, buf, num) < 0) { cerr << "Write failed" << endl; + close(outfd); stop(-EIO); return; } From patchwork Fri May 15 12:42:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 3798 Return-Path: Received: from o1.f.az.sendgrid.net (o1.f.az.sendgrid.net [208.117.55.132]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E2BFF60E13 for ; Fri, 15 May 2020 14:42:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=uajain.com header.i=@uajain.com header.b="Jks/uQxm"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uajain.com; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type; s=s1; bh=hidbZmSCedH/UeQG+0jv3X5RNRj/EkzKOHm8deO5gWc=; b=Jks/uQxmQKIOk0RnN+eZ9xa5S9OgjKiw93iZBs6fWn+FeCQEk5pAauMhb5GWz0ARoVc3 EzUXmbYs3nv698XY/TNuq42eBOL64jbazfqxS3A47Kcxzbnn3D0rBI0YKgfgQJSNuvxagr ZqmDjZdjlBiovXtBUECGPUPxzQk53yzy0= Received: by filter0084p3las1.sendgrid.net with SMTP id filter0084p3las1-1974-5EBE8E4C-A1 2020-05-15 12:42:52.854806595 +0000 UTC m=+2558464.992313740 Received: from mail.uajain.com (unknown) by ismtpd0005p1maa1.sendgrid.net (SG) with ESMTP id Bb31tzGJTlujrBoPAJbqoA Fri, 15 May 2020 12:42:52.252 +0000 (UTC) From: Umang Jain Date: Fri, 15 May 2020 12:42:52 +0000 (UTC) Message-Id: <20200515124245.18040-3-email@uajain.com> In-Reply-To: <20200515124245.18040-1-email@uajain.com> References: <20200515124245.18040-1-email@uajain.com> Mime-Version: 1.0 X-SG-EID: 1Q40EQ7YGir8a9gjSIAdTjhngY657NMk9ckeo4dbHZDiOpywc/L3L9rFqlwE4KPcofpXQ1KwJPJayd5tGsU1eE0zU8daDke3ehhqRL/kdCxt6mtbjh37tkVljdm4f4vWvqsgOrdrY9upOA2muDKs5nB+vNHsfvcyHnyHhIbiFJB11jE/WP5UHPJvn909pI48egvoXqHN56y3rAB7G7LaR2sy4Pim5FJ434utqowL7SLsouqkjOSppkW4RsgBetSW To: libcamera-devel Subject: [libcamera-devel] [PATCH v2 2/4] test: log: log_process: Close open fds on error paths 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: Fri, 15 May 2020 12:42:55 -0000 Pointed out by Coverity DefectId=279097 Signed-off-by: Umang Jain Reviewed-by: Kieran Bingham --- test/log/log_process.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/test/log/log_process.cpp b/test/log/log_process.cpp index 2df4aa4..88baa27 100644 --- a/test/log/log_process.cpp +++ b/test/log/log_process.cpp @@ -106,6 +106,7 @@ protected: memset(buf, 0, sizeof(buf)); if (read(fd, buf, sizeof(buf)) < 0) { cerr << "Failed to read tmp log file" << endl; + close(fd); return TestFail; } close(fd); From patchwork Fri May 15 12:42:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 3797 Return-Path: Received: from o1.f.az.sendgrid.net (o1.f.az.sendgrid.net [208.117.55.132]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E242660E0F for ; Fri, 15 May 2020 14:42:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=uajain.com header.i=@uajain.com header.b="pPSl68t1"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uajain.com; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type; s=s1; bh=CVlZQdEZ+lTx2UvlTlFz67zvM7i8+MT+A3eEp0ALdvk=; b=pPSl68t12Pl2UVTXpa5V3sd3CvRKl6x0AjldSh3ihHnzWSmujfXcXevjeWC1NE/rGszM 1b187QHO9+MVYWMU644Vkr7gf+gBuYENnHjlSBPVJn+ieih+ktNc085/dlFCk+fHSACYxP wcLjae2l2aOz5xF/HXoqwHmxHcVVKXyvk= Received: by filterdrecv-p3iad2-8ddf98858-rpdh9 with SMTP id filterdrecv-p3iad2-8ddf98858-rpdh9-19-5EBE8E4D-27 2020-05-15 12:42:53.614076869 +0000 UTC m=+4361719.364516320 Received: from mail.uajain.com (unknown) by ismtpd0001p1maa1.sendgrid.net (SG) with ESMTP id 18xcdec4Roe1WdGokaodIw for ; Fri, 15 May 2020 12:42:53.141 +0000 (UTC) From: Umang Jain Date: Fri, 15 May 2020 12:42:53 +0000 (UTC) Message-Id: <20200515124245.18040-4-email@uajain.com> In-Reply-To: <20200515124245.18040-1-email@uajain.com> References: <20200515124245.18040-1-email@uajain.com> Mime-Version: 1.0 X-SG-EID: 1Q40EQ7YGir8a9gjSIAdTjhngY657NMk9ckeo4dbHZDiOpywc/L3L9rFqlwE4KPcumJKJCztqrDTQNOfbQrvHfzJz5+dA5iyzk1X2aMakKJMauHf+8y4XIeDLfzKNBlhddoPRNDlJ0oVmQujTCu53m4YZXT6mjH7M16lzr/OQK15oXrHX606tl2oKRXTDQvjsCB04mL8yfvEDI12ZRAxioaxqlDTyPQTIUQcmhmyB/Sb3z+kdFeGc35BQ+ViATXzvdiqI/o2FeMz94hQgrqICA== To: libcamera-devel Subject: [libcamera-devel] [PATCH v2 3/4] test: log: log_api: Close open fds on error paths 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: Fri, 15 May 2020 12:42:55 -0000 Pointed out by Coverity DefectId=279091 Signed-off-by: Umang Jain Reviewed-by: Kieran Bingham --- test/log/log_api.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/log/log_api.cpp b/test/log/log_api.cpp index 33622f8..4d2c8db 100644 --- a/test/log/log_api.cpp +++ b/test/log/log_api.cpp @@ -86,6 +86,7 @@ protected: if (logSetFile(path) < 0) { cerr << "Failed to set log file" << endl; + close(fd); return TestFail; } @@ -96,6 +97,7 @@ protected: lseek(fd, 0, SEEK_SET); if (read(fd, buf, sizeof(buf)) < 0) { cerr << "Failed to read tmp log file" << endl; + close(fd); return TestFail; } close(fd); From patchwork Fri May 15 12:42:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 3799 Return-Path: Received: from o1.f.az.sendgrid.net (o1.f.az.sendgrid.net [208.117.55.132]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4C8E560E13 for ; Fri, 15 May 2020 14:42:56 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=uajain.com header.i=@uajain.com header.b="kRhlQZhY"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uajain.com; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type; s=s1; bh=ypx0l5S1eElZCfSsU6JNux9dqR9MqHq//0HJwRPZiXQ=; b=kRhlQZhYSMduwhgznKTjuIUNOOjSXmksmAbzA0U4rWxCTeYlijM7Fp1w14lsmSl/e/EE qkjVWnWQ7YX2RhVgqJvgMbKZ7+6JPZUSRZSJtiqK69jOzLf4cOMh7L4xmTFbCnFmFDlpDV GDc1CXccT2aZyzH+rEk4dAjqEh/u+Se2A= Received: by filter0073p3las1.sendgrid.net with SMTP id filter0073p3las1-3640-5EBE8E4E-78 2020-05-15 12:42:54.653166209 +0000 UTC m=+2558432.897400713 Received: from mail.uajain.com (unknown) by ismtpd0004p1maa1.sendgrid.net (SG) with ESMTP id oFd7B2YPR3uLTzPSq6__pw for ; Fri, 15 May 2020 12:42:54.314 +0000 (UTC) From: Umang Jain Date: Fri, 15 May 2020 12:42:54 +0000 (UTC) Message-Id: <20200515124245.18040-5-email@uajain.com> In-Reply-To: <20200515124245.18040-1-email@uajain.com> References: <20200515124245.18040-1-email@uajain.com> Mime-Version: 1.0 X-SG-EID: 1Q40EQ7YGir8a9gjSIAdTjhngY657NMk9ckeo4dbHZDiOpywc/L3L9rFqlwE4KPcHcG1g99dnq0SJ9KzJgHEPjOpQm5nI00z0W5yXxIY20eIcETDJ2Ss6SYI8o0hWQQY0W/VcDAzx52NVFzR2xL95/5ThFhdtAZmVqw1oZmMRBaCp5qCiFYCcFYR7J7oKqlAkDomGRBcm4EvbvC9G8Drm9e2636Ve23+nxTExsPgeL4xCUETGEIwyrlDMg4iHAUJ To: libcamera-devel Subject: [libcamera-devel] [PATCH v2 4/4] libcamera: camera: Return -EINVAL if any stream is null while configure() 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: Fri, 15 May 2020 12:42:58 -0000 Fail and return the Camera::configure() operation if any of the stream turns out to be a nullptr even after the PipelineHandler handler seems to have configured the config successfully. This prevents a null-dereference below in the loop. Pointed out by Coverity DefectId=279069 Signed-off-by: Umang Jain Reported-by: Coverity CID=279069 Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/libcamera/camera.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 8c3bb2c..9d2607b 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -777,9 +777,12 @@ int Camera::configure(CameraConfiguration *config) p_->activeStreams_.clear(); for (const StreamConfiguration &cfg : *config) { Stream *stream = cfg.stream(); - if (!stream) + if (!stream) { LOG(Camera, Fatal) << "Pipeline handler failed to update stream configuration"; + p_->activeStreams_.clear(); + return -EINVAL; + } stream->configuration_ = cfg; p_->activeStreams_.insert(stream);