From: Peilin Ye Date: Fri, 21 Aug 2020 15:13:43 +0000 (+0200) Subject: media: v4l2-tpg: Clamp hue in tpg_s_hue() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=45c2044ccbedd48bc2a8cddde9ce7e82f03d588c;p=linux.git media: v4l2-tpg: Clamp hue in tpg_s_hue() Setting `hue` by calling tpg_s_hue() directly is risky, since it does not perform range check. Clamp `hue` to the valid range in tpg_s_hue(). Suggested-by: Hans Verkuil Signed-off-by: Peilin Ye Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- diff --git a/include/media/tpg/v4l2-tpg.h b/include/media/tpg/v4l2-tpg.h index 0b0ddb87380ed..181dcbe777f39 100644 --- a/include/media/tpg/v4l2-tpg.h +++ b/include/media/tpg/v4l2-tpg.h @@ -325,6 +325,7 @@ static inline void tpg_s_saturation(struct tpg_data *tpg, static inline void tpg_s_hue(struct tpg_data *tpg, s16 hue) { + hue = clamp_t(s16, hue, -128, 128); if (tpg->hue == hue) return; tpg->hue = hue;