[{"id":1519,"web_url":"https://patchwork.libcamera.org/comment/1519/","msgid":"<20190427091951.GA4690@pendragon.ideasonboard.com>","date":"2019-04-27T09:19:51","subject":"Re: [libcamera-devel] [PATCH v2] libcamera: camera: Check requests\n\tbefore queueing them","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Niklas,\n\nThank you for the patch.\n\nOn Fri, Apr 26, 2019 at 04:13:32PM +0200, Niklas Söderlund wrote:\n> Make sure all requests queued to a camera only contain streams which\n> have been configured and belong to the camera.\n> \n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/libcamera/camera.cpp | 9 +++++++++\n>  1 file changed, 9 insertions(+)\n> \n> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\n> index 655996f26224ef49..9cea3fd06238c1cb 100644\n> --- a/src/libcamera/camera.cpp\n> +++ b/src/libcamera/camera.cpp\n> @@ -732,6 +732,7 @@ Request *Camera::createRequest()\n>   * \\return 0 on success or a negative error code otherwise\n>   * \\retval -ENODEV The camera has been disconnected from the system\n>   * \\retval -EACCES The camera is not running so requests can't be queued\n> + * \\retval -EINVAL The request is invalid\n>   */\n>  int Camera::queueRequest(Request *request)\n>  {\n> @@ -741,6 +742,14 @@ int Camera::queueRequest(Request *request)\n>  \tif (!stateIs(CameraRunning))\n>  \t\treturn -EACCES;\n>  \n> +\tfor (auto const &it : request->buffers()) {\n> +\t\tStream *stream = it.first;\n> +\t\tif (activeStreams_.find(stream) == activeStreams_.end()) {\n> +\t\t\tLOG(Camera, Error) << \"Invalid request\";\n> +\t\t\treturn -EINVAL;\n> +\t\t}\n> +\t}\n> +\n>  \tint ret = request->prepare();\n>  \tif (ret) {\n>  \t\tLOG(Camera, Error) << \"Failed to prepare request\";","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["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 7CDB760E99\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 27 Apr 2019 11:20:08 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(net-37-182-44-227.cust.vodafonedsl.it [37.182.44.227])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E39625F;\n\tSat, 27 Apr 2019 11:20:07 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1556356808;\n\tbh=mnuKdsY2lMzyujVlPqyGFX12zD4Ck2jY2/F+xPrIiK0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=GlOBdW/+OL4VaRFs+m1b/PJVEAyAl4IZ4Nb1GQCaMFKDFCs++wQTTheawKei7pVb2\n\tuc14X02JuY7QnqmzLmAZzKxf8ZvyZVBJx1+JV1RD/IioHtwmtrC48oSdTus9IObyW5\n\tpWq/C6lO/w1PzExeIUQ1XMiTyUpVaj3T7ys0Nfiw=","Date":"Sat, 27 Apr 2019 12:19:51 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190427091951.GA4690@pendragon.ideasonboard.com>","References":"<20190426141332.2782-1-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190426141332.2782-1-niklas.soderlund@ragnatech.se>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v2] libcamera: camera: Check requests\n\tbefore queueing them","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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>","X-List-Received-Date":"Sat, 27 Apr 2019 09:20:08 -0000"}},{"id":1523,"web_url":"https://patchwork.libcamera.org/comment/1523/","msgid":"<20190428093621.GH16573@bigcity.dyn.berto.se>","date":"2019-04-28T09:36:21","subject":"Re: [libcamera-devel] [PATCH v2] libcamera: camera: Check requests\n\tbefore queueing them","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi,\n\nOn 2019-04-27 12:19:51 +0300, Laurent Pinchart wrote:\n> Hi Niklas,\n> \n> Thank you for the patch.\n> \n> On Fri, Apr 26, 2019 at 04:13:32PM +0200, Niklas Söderlund wrote:\n> > Make sure all requests queued to a camera only contain streams which\n> > have been configured and belong to the camera.\n> > \n> > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nThanks, pushed to master.\n\n> \n> > ---\n> >  src/libcamera/camera.cpp | 9 +++++++++\n> >  1 file changed, 9 insertions(+)\n> > \n> > diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\n> > index 655996f26224ef49..9cea3fd06238c1cb 100644\n> > --- a/src/libcamera/camera.cpp\n> > +++ b/src/libcamera/camera.cpp\n> > @@ -732,6 +732,7 @@ Request *Camera::createRequest()\n> >   * \\return 0 on success or a negative error code otherwise\n> >   * \\retval -ENODEV The camera has been disconnected from the system\n> >   * \\retval -EACCES The camera is not running so requests can't be queued\n> > + * \\retval -EINVAL The request is invalid\n> >   */\n> >  int Camera::queueRequest(Request *request)\n> >  {\n> > @@ -741,6 +742,14 @@ int Camera::queueRequest(Request *request)\n> >  \tif (!stateIs(CameraRunning))\n> >  \t\treturn -EACCES;\n> >  \n> > +\tfor (auto const &it : request->buffers()) {\n> > +\t\tStream *stream = it.first;\n> > +\t\tif (activeStreams_.find(stream) == activeStreams_.end()) {\n> > +\t\t\tLOG(Camera, Error) << \"Invalid request\";\n> > +\t\t\treturn -EINVAL;\n> > +\t\t}\n> > +\t}\n> > +\n> >  \tint ret = request->prepare();\n> >  \tif (ret) {\n> >  \t\tLOG(Camera, Error) << \"Failed to prepare request\";\n> \n> -- \n> Regards,\n> \n> Laurent Pinchart","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lj1-x243.google.com (mail-lj1-x243.google.com\n\t[IPv6:2a00:1450:4864:20::243])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2070B60B7E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 28 Apr 2019 11:36:24 +0200 (CEST)","by mail-lj1-x243.google.com with SMTP id e18so798832lja.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 28 Apr 2019 02:36:24 -0700 (PDT)","from localhost (89-233-230-99.cust.bredband2.com. [89.233.230.99])\n\tby smtp.gmail.com with ESMTPSA id\n\tw22sm6217458ljd.42.2019.04.28.02.36.22\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tSun, 28 Apr 2019 02:36:22 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to\n\t:user-agent; bh=i6IQI/3kieYShdoGlSXnSMYuDSs3btQMHe3ahlXLy7g=;\n\tb=v5Vn2IdwpCz7AyqlQUV9ZAeT5FtyrlVl+8MWGRRMHeHcQtJAabVXDa8KLjeyFOYPfg\n\tFD0Q7PZ607xlQykDIgGyJimN25GkajCtHjn6rGu5+pOLR4pBvBKkVdpqWx0xkmSC9k9D\n\tDLLLDkUIxuenn1GhGhwVIhJc+vApa6TNjF2ztr2Q46wbB7iXIYAPSY+QX8guxSzpbOkN\n\tPuB6Qt4j5tzHn7P9jvhDrYc22moe/f8EoE1iSDsWAXe5c+8ovpNc0ZZz5izOwxnMEVX/\n\tso1oCZklx8uRp8/QoefCknPwqc1N2UVsSk9KObqDqtpa4EHTOzeiBEhQCFKhefAGac+Q\n\tDuSw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to:user-agent;\n\tbh=i6IQI/3kieYShdoGlSXnSMYuDSs3btQMHe3ahlXLy7g=;\n\tb=isarCneTJHHbB7YNut4A09ZODDAWMeS4WuusNZZDlSoGf8SQMmRz4GyqB/j3diLfhF\n\taynLCjdv+wy20eM0NIfJnr6iM2GpsHWl/RXknq8JDBOG4gOnDnRWyh86XY3W9ame7ZdY\n\tFdHhxzeUyEhFNxufM3HcQblBGv36CJzSFqnZhhIK6klMu+YLU15YgIDk9ovmPhBWoQMe\n\tWtVI2MzAY/2w8u6fW3M6kxRr3c/oez5s++sHMAsqtpWiBSi0V0Z8kCn1jp2RX3Xt42/7\n\tk0DIOTCFVJVCi1NlAOPgdmpi/EhrLZnY3em4wktA3vIdv+bXsAFj5ZrJmx0Wu5v16igq\n\tvvfw==","X-Gm-Message-State":"APjAAAWYnFi+8QJnTKrbLKO1F3QYQXrVNM1bY8QBDl0XF7k2qi+Gdysd\n\t0aUk4ZrXuSnKpDffut7KU88Lkr4j8Cs=","X-Google-Smtp-Source":"APXvYqxggrztrLdBEs16dApOAF5I8q8QF4XpqIRYGuoTIu8dz0AmaDLMQnVZ9TuE/4DEk4W9XW2oOg==","X-Received":"by 2002:a2e:80d4:: with SMTP id\n\tr20mr6871240ljg.173.1556444183299; \n\tSun, 28 Apr 2019 02:36:23 -0700 (PDT)","Date":"Sun, 28 Apr 2019 11:36:21 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190428093621.GH16573@bigcity.dyn.berto.se>","References":"<20190426141332.2782-1-niklas.soderlund@ragnatech.se>\n\t<20190427091951.GA4690@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190427091951.GA4690@pendragon.ideasonboard.com>","User-Agent":"Mutt/1.11.3 (2019-02-01)","Subject":"Re: [libcamera-devel] [PATCH v2] libcamera: camera: Check requests\n\tbefore queueing them","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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>","X-List-Received-Date":"Sun, 28 Apr 2019 09:36:24 -0000"}}]