Uint32 underflow in R35.4.1 kernel tegracam_ctrls.c (min_gain_val)

The new Jetpack 5.1.2 kernel has a uint32 underflow bug where the min_gain_val has 1 subtracted from it as a uint32, before an implicit cast to signed sint64, resulting in a check_range() validation failure (because min becomes greater than max if set to 0 (which is a valid min gain)).

A workaround is to edit DTBs to use a min gain of 1 instead of 0 but fundamentally this is a casting bug in the kernel sources.
The developer probably meant to cast to sint64 before doing the subtraction

((__s64) ctrlprops->min_gain_val) - 1

The failed range check (when using a min gain of 0) manifests as a -34 error during driver load:

[   12.717909] imx462 202-001a: probing v4l2 sensor
[   12.717998] imx462 202-001a: initializing mipi...
[   12.723783] imx462 202-001a: tegracam sensor driver:imx462_v2.0.6
[   12.794224] imx462 202-001a: ctrl Gain range update failed
[   12.800117] imx462 202-001a: Error -34 updating mode specific control ranges 
[   12.807501] imx462 202-001a: Error -34 updating control ranges
[   12.813614] imx462 202-001a: Failed to init ctrls imx462
[   12.825898] imx462 202-001a: tegra camera subdev registration failed
[   12.832620] imx462: probe of 202-001a failed with error -34
[   12.838429] imx462 203-001a: probing v4l2 sensor
[   12.838491] imx462 203-001a: initializing mipi...
[   12.846784] imx462 203-001a: tegracam sensor driver:imx462_v2.0.6
[   12.909648] imx462 203-001a: ctrl Gain range update failed
[   12.917777] imx462 203-001a: Error -34 updating mode specific control ranges 
[   12.927866] imx462 203-001a: Error -34 updating control ranges
[   12.937600] imx462 203-001a: Failed to init ctrls imx462
[   12.944988] imx462 203-001a: tegra camera subdev registration failed
[   12.955145] imx462: probe of 203-001a failed with error -34

please check Release Notes (r35.4.1) for known issue-4189361

To avoid a probe failure, the min_gain_val param sensors in DT should be set to greater than 1 in linear scale.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.