[libcamera-devel,1/5] libcamera: camera: Fix access bug in configureStreams()

Message ID 20190306024755.28726-2-niklas.soderlund@ragnatech.se
State Superseded
Headers show
Series
  • test: camera: Add basic tests for the camera
Related show

Commit Message

Niklas Söderlund March 6, 2019, 2:47 a.m. UTC
It is not permitted to configure streams before a camera is acquired.

Fixes: 77100a7578d8a0cc ("libcamera: camera: add state machine to control access from applications")
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
---
 src/libcamera/camera.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Laurent Pinchart March 10, 2019, 1:16 p.m. UTC | #1
Hi Niklas,

Thank you for the patch.

On Wed, Mar 06, 2019 at 03:47:51AM +0100, Niklas Söderlund wrote:
> It is not permitted to configure streams before a camera is acquired.
> 
> Fixes: 77100a7578d8a0cc ("libcamera: camera: add state machine to control access from applications")
> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  src/libcamera/camera.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
> index e3144c5b4ab093b2..8ee9cc0866167ae1 100644
> --- a/src/libcamera/camera.cpp
> +++ b/src/libcamera/camera.cpp
> @@ -405,7 +405,7 @@ int Camera::configureStreams(std::map<Stream *, StreamConfiguration> &config)
>  	if (disconnected_)
>  		return -ENODEV;
>  
> -	if (!stateBetween(CameraAvailable, CameraConfigured))
> +	if (!stateBetween(CameraAcquired, CameraConfigured))
>  		return -EACCES;
>  
>  	if (!config.size()) {
Niklas Söderlund March 10, 2019, 10:28 p.m. UTC | #2
Hi Laurent,

Thanks for your feedback.

On 2019-03-10 15:16:07 +0200, Laurent Pinchart wrote:
> Hi Niklas,
> 
> Thank you for the patch.
> 
> On Wed, Mar 06, 2019 at 03:47:51AM +0100, Niklas Söderlund wrote:
> > It is not permitted to configure streams before a camera is acquired.
> > 
> > Fixes: 77100a7578d8a0cc ("libcamera: camera: add state machine to control access from applications")
> > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

As this patch is a bug fix and not strictly related to the addition of 
the camera tests the rest of this series deals with I have pushed this 
fix with your tag, thanks!

> 
> > ---
> >  src/libcamera/camera.cpp | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
> > index e3144c5b4ab093b2..8ee9cc0866167ae1 100644
> > --- a/src/libcamera/camera.cpp
> > +++ b/src/libcamera/camera.cpp
> > @@ -405,7 +405,7 @@ int Camera::configureStreams(std::map<Stream *, StreamConfiguration> &config)
> >  	if (disconnected_)
> >  		return -ENODEV;
> >  
> > -	if (!stateBetween(CameraAvailable, CameraConfigured))
> > +	if (!stateBetween(CameraAcquired, CameraConfigured))
> >  		return -EACCES;
> >  
> >  	if (!config.size()) {
> 
> -- 
> Regards,
> 
> Laurent Pinchart

Patch

diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
index e3144c5b4ab093b2..8ee9cc0866167ae1 100644
--- a/src/libcamera/camera.cpp
+++ b/src/libcamera/camera.cpp
@@ -405,7 +405,7 @@  int Camera::configureStreams(std::map<Stream *, StreamConfiguration> &config)
 	if (disconnected_)
 		return -ENODEV;
 
-	if (!stateBetween(CameraAvailable, CameraConfigured))
+	if (!stateBetween(CameraAcquired, CameraConfigured))
 		return -EACCES;
 
 	if (!config.size()) {