[libcamera-devel] pipeline: rkisp1: Add check for non-existent frame info
diff mbox series

Message ID 20210411164858.29961-1-sebastian.fricke@posteo.net
State Accepted
Commit 093b71b24a361900bcb9c8a76ee7ad85943f4f5b
Headers show
Series
  • [libcamera-devel] pipeline: rkisp1: Add check for non-existent frame info
Related show

Commit Message

Sebastian Fricke April 11, 2021, 4:48 p.m. UTC
Add a check, that makes sure that the given FrameBuffer is associated
to a RkISP1FrameInfo instance. The current code tries to access the
frame info without checking if it actually exists.

Fixes: 0eb65e14e libcamera: pipeline: rkisp1: Attach to an IPA

Signed-off-by: Sebastian Fricke <sebastian.fricke@posteo.net>
---
 src/libcamera/pipeline/rkisp1/rkisp1.cpp | 2 ++
 1 file changed, 2 insertions(+)

Comments

Kieran Bingham April 12, 2021, 8:03 p.m. UTC | #1
Hi Sebastian,

On 11/04/2021 17:48, Sebastian Fricke wrote:
> Add a check, that makes sure that the given FrameBuffer is associated
> to a RkISP1FrameInfo instance. The current code tries to access the
> frame info without checking if it actually exists.
> 
> Fixes: 0eb65e14e libcamera: pipeline: rkisp1: Attach to an IPA
> 
> Signed-off-by: Sebastian Fricke <sebastian.fricke@posteo.net>
> ---
>  src/libcamera/pipeline/rkisp1/rkisp1.cpp | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> index 03757327..eca7d608 100644
> --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> @@ -1079,6 +1079,8 @@ void PipelineHandlerRkISP1::paramReady(FrameBuffer *buffer)
>  	RkISP1CameraData *data = cameraData(activeCamera_);
>  
>  	RkISP1FrameInfo *info = data->frameInfo_.find(buffer);
> +	if (!info)
> +		return;

If the frameInfo can't find what it's looking for, then that should be a
fatal error (if it's not already) ... but even if it's Fatal, I think
it's best to make sure the return paths on FATAL's are handled as we may
choose to cause FATAL to not assert in non-debug builds.

Along with that, other code paths do check this and return accordingly,
so this improves consistency.


So

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

>  
>  	info->paramDequeued = true;
>  	tryCompleteRequest(info->request);
>
Sebastian Fricke May 3, 2021, 11:51 a.m. UTC | #2
Hey,

slight push .. :)

On 11.04.2021 18:48, Sebastian Fricke wrote:
>Add a check, that makes sure that the given FrameBuffer is associated
>to a RkISP1FrameInfo instance. The current code tries to access the
>frame info without checking if it actually exists.
>
>Fixes: 0eb65e14e libcamera: pipeline: rkisp1: Attach to an IPA
>
>Signed-off-by: Sebastian Fricke <sebastian.fricke@posteo.net>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
>---
> src/libcamera/pipeline/rkisp1/rkisp1.cpp | 2 ++
> 1 file changed, 2 insertions(+)
>
>diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
>index 03757327..eca7d608 100644
>--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
>+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
>@@ -1079,6 +1079,8 @@ void PipelineHandlerRkISP1::paramReady(FrameBuffer *buffer)
> 	RkISP1CameraData *data = cameraData(activeCamera_);
>
> 	RkISP1FrameInfo *info = data->frameInfo_.find(buffer);
>+	if (!info)
>+		return;
>
> 	info->paramDequeued = true;
> 	tryCompleteRequest(info->request);
>-- 
>2.25.1
>
Kieran Bingham May 3, 2021, 12:34 p.m. UTC | #3
Hi Sebastian,

On 03/05/2021 12:51, Sebastian Fricke wrote:
> Hey,
> 
> slight push .. :)

I'll push this in now.
--
Kieran


> 
> On 11.04.2021 18:48, Sebastian Fricke wrote:
>> Add a check, that makes sure that the given FrameBuffer is associated
>> to a RkISP1FrameInfo instance. The current code tries to access the
>> frame info without checking if it actually exists.
>>
>> Fixes: 0eb65e14e libcamera: pipeline: rkisp1: Attach to an IPA
>>
>> Signed-off-by: Sebastian Fricke <sebastian.fricke@posteo.net>
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
>> ---
>> src/libcamera/pipeline/rkisp1/rkisp1.cpp | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
>> b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
>> index 03757327..eca7d608 100644
>> --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
>> +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
>> @@ -1079,6 +1079,8 @@ void
>> PipelineHandlerRkISP1::paramReady(FrameBuffer *buffer)
>>     RkISP1CameraData *data = cameraData(activeCamera_);
>>
>>     RkISP1FrameInfo *info = data->frameInfo_.find(buffer);
>> +    if (!info)
>> +        return;
>>
>>     info->paramDequeued = true;
>>     tryCompleteRequest(info->request);
>> -- 
>> 2.25.1
>>

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
index 03757327..eca7d608 100644
--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
@@ -1079,6 +1079,8 @@  void PipelineHandlerRkISP1::paramReady(FrameBuffer *buffer)
 	RkISP1CameraData *data = cameraData(activeCamera_);
 
 	RkISP1FrameInfo *info = data->frameInfo_.find(buffer);
+	if (!info)
+		return;
 
 	info->paramDequeued = true;
 	tryCompleteRequest(info->request);