On Fri, Aug 21, 2020 at 12:12:28PM +0200, Hans Verkuil wrote: > Arrgh! I know what this is. /dev/video6 corresponds to the Metadata output > device of vivid, and that metadata format sets brightness, contrast, > saturation and hue: > > struct vivid_meta_out_buf { > u16 brightness; > u16 contrast; > u16 saturation; > s16 hue; > }; > > vivid_meta_out_process() calls tpg_s_* functions to set these values. But > this is wrong, it should set the corresponding V4L2 controls instead since > calling these tpg_s_* functions bypasses all range checks. It also will > not update the controls themselves, so they are out-of-sync with the actual > values. I.e. the test pattern generator uses different values compared to > the values in the controls. > > So two patches are needed: > > 1) a patch for include/media/tpg/v4l2-tpg.h where tpg_s_hue will clamp the > hue value to the valid range. This to prevent anyone else from setting invalid > hue values in the tpg. > > 2) a patch for drivers/media/test-drivers/vivid/vivid-meta-out.c where, > instead of calling the tpg_s_* functions in vivid_meta_out_process(), it > calls instead: > > v4l2_ctrl_s_ctrl(dev->brightness, meta->brightness); > v4l2_ctrl_s_ctrl(dev->contrast, meta->contrast); > etc. > > Do patch 2 first and test with syzkaller to check that by going through the > controls this issue is resolved. Since with that approach the tpg should > always get valid hue values. Ah, now it all makes sense! Thank you! I will do them now. Peilin