[PATCH] ipa: rpi: Prevent segfault if AGC algorithm is absent

Kieran Bingham kieran.bingham at ideasonboard.com
Thu May 29 12:48:50 CEST 2025


Hi Naush,

Quoting Benjamin Mugnier (2025-05-23 10:56:56)
> Even without AGC definition in the tuning file, the application would
> still dereference agc unconditionally, leading to a segmentation fault
> if AGC is absent.
> This is relevant for sensors already providing AGC/AEC by themselves.
> Check if AGC is present prior to setting maximum exposure time.

Any opinion on this ?

I'm preparing/planning for the next libcamera release and I'm curious if
this should be in or not.

Regards

Kieran

> 
> Signed-off-by: Benjamin Mugnier <benjamin.mugnier at foss.st.com>
> ---
>  src/ipa/rpi/common/ipa_base.cpp | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp
> index e0a93daa9db229bb2829803fffc6b2f6c8f11061..e0f8b7e782f4340a069a2d7b9cf9dee3141c72df 100644
> --- a/src/ipa/rpi/common/ipa_base.cpp
> +++ b/src/ipa/rpi/common/ipa_base.cpp
> @@ -1563,7 +1563,8 @@ void IpaBase::applyFrameDurations(Duration minFrameDuration, Duration maxFrameDu
>  
>         RPiController::AgcAlgorithm *agc = dynamic_cast<RPiController::AgcAlgorithm *>(
>                 controller_.getAlgorithm("agc"));
> -       agc->setMaxExposureTime(maxExposureTime);
> +       if (agc)
> +               agc->setMaxExposureTime(maxExposureTime);
>  }
>  
>  void IpaBase::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls)
> 
> ---
> base-commit: ad5326c926831fe7a943d10fd800de43e596f171
> change-id: 20250523-fix_segfault_agc-5f2735edec5f
> 
> Best regards,
> -- 
> Benjamin Mugnier <benjamin.mugnier at foss.st.com>
>


More information about the libcamera-devel mailing list