[{"id":24953,"web_url":"https://patchwork.libcamera.org/comment/24953/","msgid":"<Yxj7cIL6Lj7pu9ZH@pendragon.ideasonboard.com>","date":"2022-09-07T20:13:36","subject":"Re: [libcamera-devel] [PATCH 1/1] qcam: Fix crash when switching\n\tfrom non existant camera","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Utkarsh,\n\nThank you for the patch.\n\nOn Wed, Sep 07, 2022 at 10:05:04PM +0530, Utkarsh Tiwari via libcamera-devel wrote:\n> When switching to different camera we try to release the camera\n> previously used. But if that camera has been unplugged, then its\n> instance would have been destroyed. Accessing it leads to seg fault.\n> \n> Fix by checking camera_ to see if it exists.\n> \n> Bug: https://bugs.libcamera.org/show_bug.cgi?id=147\n> Signed-off-by: Utkarsh Tiwari <utkarsh02t@gmail.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/qcam/main_window.cpp | 4 +++-\n>  1 file changed, 3 insertions(+), 1 deletion(-)\n> \n> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\n> index 6fe36168..e0e5092e 100644\n> --- a/src/qcam/main_window.cpp\n> +++ b/src/qcam/main_window.cpp\n> @@ -284,7 +284,9 @@ void MainWindow::switchCamera()\n>  \t */\n>  \tstartStopAction_->setChecked(false);\n>  \n> -\tcamera_->release();\n> +\tif (camera_)\n> +\t\tcamera_->release();\n> +\n>  \tcamera_ = cam;\n>  \n>  \tstartStopAction_->setChecked(true);","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 85368C3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  7 Sep 2022 20:13:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A3C3062090;\n\tWed,  7 Sep 2022 22:13:54 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3B74262054\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  7 Sep 2022 22:13:53 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 70874888;\n\tWed,  7 Sep 2022 22:13:52 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1662581634;\n\tbh=qN3YQAAh5jB6NWunXRk5rsRVETvkKBujC9D7FXFQ1cg=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=C0UETJJib9S9JnomRIzxgV9vetAdKWxDxYQvBzmwR6rpmI+0COdms8FMuBFNZaVbb\n\tuHa7nLKhJB1Pg6c29qqx4lbmJsXu1FimmvTTwa5sZ066fHUD78mZcRhtMsE+ZEDKK3\n\tfaA9CIhRey5RtbQ6yySrLXrlBr9+8NVzFCMYSHGjCLD16nx4DU3dtnBYgXn3ZnKuDe\n\tunqg+T5ZducWYBAje/aLkouqs8oMj5xwKh1f/jlnkDFc8yGjsACuzs6Cq0HxXBUkVH\n\tLjfXQMvRGp/43c+84rV0rWbPkXGlxA9SvjN0EYihugJuLnxu/A2+vp4QX1H5Lga+ri\n\t90PkI9YlDi4sA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1662581632;\n\tbh=qN3YQAAh5jB6NWunXRk5rsRVETvkKBujC9D7FXFQ1cg=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=E9Nff0+fcA7c73iuQeoNWFTK0uw/F8rHJPfe8lIQUz7epxVcB6sz1+o0FT4ymAwOS\n\taMBUECwxA2H2FkJxzKlWfFG9+yNLI9XyrjfEkPlmO80yJHCvvP3z+HOfyC70NKoFmx\n\t/4pfBpFqblRURr7Wjx5MIPAeHDj8aJx3JVDz3JeY="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"E9Nff0+f\"; dkim-atps=neutral","Date":"Wed, 7 Sep 2022 23:13:36 +0300","To":"Utkarsh Tiwari <utkarsh02t@gmail.com>","Message-ID":"<Yxj7cIL6Lj7pu9ZH@pendragon.ideasonboard.com>","References":"<20220907163504.209658-1-utkarsh02t@gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220907163504.209658-1-utkarsh02t@gmail.com>","Subject":"Re: [libcamera-devel] [PATCH 1/1] qcam: Fix crash when switching\n\tfrom non existant camera","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":24954,"web_url":"https://patchwork.libcamera.org/comment/24954/","msgid":"<166258675523.2677993.17845928418550234468@Monstersaurus>","date":"2022-09-07T21:39:15","subject":"Re: [libcamera-devel] [PATCH 1/1] qcam: Fix crash when switching\n\tfrom non existant camera","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Laurent Pinchart via libcamera-devel (2022-09-07 21:13:36)\n> Hi Utkarsh,\n> \n> Thank you for the patch.\n> \n> On Wed, Sep 07, 2022 at 10:05:04PM +0530, Utkarsh Tiwari via libcamera-devel wrote:\n> > When switching to different camera we try to release the camera\n> > previously used. But if that camera has been unplugged, then its\n> > instance would have been destroyed. Accessing it leads to seg fault.\n> > \n> > Fix by checking camera_ to see if it exists.\n> > \n> > Bug: https://bugs.libcamera.org/show_bug.cgi?id=147\n> > Signed-off-by: Utkarsh Tiwari <utkarsh02t@gmail.com>\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nTested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> > ---\n> >  src/qcam/main_window.cpp | 4 +++-\n> >  1 file changed, 3 insertions(+), 1 deletion(-)\n> > \n> > diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\n> > index 6fe36168..e0e5092e 100644\n> > --- a/src/qcam/main_window.cpp\n> > +++ b/src/qcam/main_window.cpp\n> > @@ -284,7 +284,9 @@ void MainWindow::switchCamera()\n> >        */\n> >       startStopAction_->setChecked(false);\n> >  \n> > -     camera_->release();\n> > +     if (camera_)\n> > +             camera_->release();\n> > +\n> >       camera_ = cam;\n> >  \n> >       startStopAction_->setChecked(true);\n> \n> -- \n> Regards,\n> \n> Laurent Pinchart","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 074A8C0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  7 Sep 2022 21:39:21 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5E92062090;\n\tWed,  7 Sep 2022 23:39:20 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A62F762054\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  7 Sep 2022 23:39:18 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1B829888;\n\tWed,  7 Sep 2022 23:39:18 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1662586760;\n\tbh=7+H58t5g9TBDhO7fpfs6oZA1qbbNb8ZYI8c1ZlBBXas=;\n\th=In-Reply-To:References:To:Date:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=c4w59WVzBnQwUIaEbCbadeJdRFegzcrSDox2USwrqaRDGe4wl32Xh5k8VKqdscKrt\n\tDwACdCuXc2yTp9RdfczMx89bxR0nLKLvF2AMZOczxNU9jgXJ4qiYQxMuQKmKQxiPG/\n\t+Vm8poGbdXrnFz6aCVnFvMonGcM9dcE0pfz9ZCvSxKIW4bVkCCigRG2Eh06qrOcys4\n\t/X4dvkx3NIdQTkblxuB/2AURCacUaP/bycI8mcyAnoWvVmpfSMLv+Ugxns7X0mkKxy\n\tcmrWedE7Fa7zhx6BwZeAhJwe1aMk8rDkDMTlg8CsQ/XVMifURZpDUACwsutE4EJokY\n\tMrszvnat02E1w==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1662586758;\n\tbh=7+H58t5g9TBDhO7fpfs6oZA1qbbNb8ZYI8c1ZlBBXas=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=WJJE9+lie6dDR2//WdAYBhNDWPyBtJNVNr6lQYKVn9465DPjQas8XT5v/Njar7x97\n\tqPGuGXj38lymJ4QclzSn2Bhc87vlWHLzkhzFIXGfbiDA8LmGAaBgFZ8dzQVF4o7Ynk\n\tL3XkfKUeukvHYfv0jy2yvoKBtnGSKOjpMfYV5Vf8="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"WJJE9+li\"; dkim-atps=neutral","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<Yxj7cIL6Lj7pu9ZH@pendragon.ideasonboard.com>","References":"<20220907163504.209658-1-utkarsh02t@gmail.com>\n\t<Yxj7cIL6Lj7pu9ZH@pendragon.ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tLaurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>, \n\tUtkarsh Tiwari <utkarsh02t@gmail.com>","Date":"Wed, 07 Sep 2022 22:39:15 +0100","Message-ID":"<166258675523.2677993.17845928418550234468@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH 1/1] qcam: Fix crash when switching\n\tfrom non existant camera","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":24955,"web_url":"https://patchwork.libcamera.org/comment/24955/","msgid":"<20220908050506.GA609776@pyrite.rasen.tech>","date":"2022-09-08T05:05:06","subject":"Re: [libcamera-devel] [PATCH 1/1] qcam: Fix crash when switching\n\tfrom non existant camera","submitter":{"id":97,"url":"https://patchwork.libcamera.org/api/people/97/","name":"Nicolas Dufresne via libcamera-devel","email":"libcamera-devel@lists.libcamera.org"},"content":"On Wed, Sep 07, 2022 at 10:05:04PM +0530, Utkarsh Tiwari via libcamera-devel wrote:\n> When switching to different camera we try to release the camera\n> previously used. But if that camera has been unplugged, then its\n> instance would have been destroyed. Accessing it leads to seg fault.\n> \n> Fix by checking camera_ to see if it exists.\n> \n> Bug: https://bugs.libcamera.org/show_bug.cgi?id=147\n> Signed-off-by: Utkarsh Tiwari <utkarsh02t@gmail.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  src/qcam/main_window.cpp | 4 +++-\n>  1 file changed, 3 insertions(+), 1 deletion(-)\n> \n> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\n> index 6fe36168..e0e5092e 100644\n> --- a/src/qcam/main_window.cpp\n> +++ b/src/qcam/main_window.cpp\n> @@ -284,7 +284,9 @@ void MainWindow::switchCamera()\n>  \t */\n>  \tstartStopAction_->setChecked(false);\n>  \n> -\tcamera_->release();\n> +\tif (camera_)\n> +\t\tcamera_->release();\n> +\n>  \tcamera_ = cam;\n>  \n>  \tstartStopAction_->setChecked(true);\n> -- \n> 2.34.1\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 028F9C0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  8 Sep 2022 05:05:14 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5E4C362095;\n\tThu,  8 Sep 2022 07:05:14 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D1D6A6208F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  8 Sep 2022 07:05:13 +0200 (CEST)","from pyrite.rasen.tech (h175-177-042-159.catv02.itscom.jp\n\t[175.177.42.159])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1E9BA6CC;\n\tThu,  8 Sep 2022 07:05:11 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1662613514;\n\tbh=vjTbbl8pz6zkFMGf/XelP9LO/1pZJXGLNvBrCqDrFT4=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=hNp8H8MWJ7ULte33q77VGtaWyrtaFYC2n2bmUV402CkZ/5MS6qR3pLX8YK3xlp3+H\n\t89U1LKJ1PAZJkfcbxd0UP8RXG2m89PSMz1jsiHtmeKLKdduq/9GcS70RzX9KzpqvnV\n\tRc1Z3XnbAf5RpsuQt8mkGFYx6Eg4977xrhp7dpTMorbBZLqA5+fMFRluHaByDoGnFA\n\tSke6w25yf2SUqRUdofCw+d21r0sd8qlDzTPl7U23R+UHqgHCZUgo22SuJuuxRBzT0M\n\txgMwbkudd3m2v80SbUCzfw5Q7pIN9RzYB91CBRo7hxbzd0bRxrGgC0X2vPt9pKjYHW\n\tW6Z5OTLf3fDZw==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1662613513;\n\tbh=vjTbbl8pz6zkFMGf/XelP9LO/1pZJXGLNvBrCqDrFT4=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=aWicJ0OhXyTLshjhHuKWDeyK+5w85JwJ2XqvBz886xbdm3JkrG8vrb462NOiirSlp\n\tqGvsrOBkI9X6xswN34SFrBmFzIsSx5DsI1elkxAuco+OgS1aUpcUp4moXKyheWA5Z+\n\t2N6sB10uiHil6QMVj3R0QQJ0oJ3JlEae2UclQAaw="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"aWicJ0Oh\"; dkim-atps=neutral","Date":"Thu, 8 Sep 2022 14:05:06 +0900","To":"Utkarsh Tiwari <utkarsh02t@gmail.com>","Message-ID":"<20220908050506.GA609776@pyrite.rasen.tech>","References":"<20220907163504.209658-1-utkarsh02t@gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20220907163504.209658-1-utkarsh02t@gmail.com>","Subject":"Re: [libcamera-devel] [PATCH 1/1] qcam: Fix crash when switching\n\tfrom non existant camera","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Paul Elder via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"paul.elder@ideasonboard.com","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]