[v5,11/36] ipa: libipa: lsc_polynomial: Fix polynomial parsing error
diff mbox series

Message ID 20260708-libipa-algorithms-v5-11-0759d0359f52@ideasonboard.com
State New
Headers show
Series
  • ipa: libipa: Introduce libipa algorithms
Related show

Commit Message

Jacopo Mondi July 8, 2026, 3:50 p.m. UTC
If any of the polynomial component is missing in the tuning file the
ValueNode::Accessor<ipa::LscPolynomial> specialization emits an
error message but continues and dereferences a potentially
invalid object.

Fix it by returning std::nullopt if a polynomial component is missing.

The caller already checks if the returned value is valid or not, causing
the algorithm initialization to fail if the tuning file is invalid.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
 src/ipa/libipa/lsc_polynomial.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/src/ipa/libipa/lsc_polynomial.h b/src/ipa/libipa/lsc_polynomial.h
index d7d9ae42e360..a0d27c4b21d6 100644
--- a/src/ipa/libipa/lsc_polynomial.h
+++ b/src/ipa/libipa/lsc_polynomial.h
@@ -94,9 +94,11 @@  struct ValueNode::Accessor<ipa::LscPolynomial> {
 		std::optional<double> k3 = obj["k3"].get<double>();
 		std::optional<double> k4 = obj["k4"].get<double>();
 
-		if (!(cx && cy && k0 && k1 && k2 && k3 && k4))
+		if (!(cx && cy && k0 && k1 && k2 && k3 && k4)) {
 			LOG(LscPolynomial, Error)
 				<< "Polynomial is missing a parameter";
+			return std::nullopt;
+		}
 
 		return ipa::LscPolynomial(*cx, *cy, *k0, *k1, *k2, *k3, *k4);
 	}