Skip to content

Commit

Permalink
media: v4l2-tpg: Clamp hue in tpg_s_hue()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Peilin Ye <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
peilin-ye authored and mchehab committed Aug 26, 2020
1 parent e3158a5 commit 45c2044
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions include/media/tpg/v4l2-tpg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 45c2044

Please sign in to comment.