summaryrefslogtreecommitdiffstats
path: root/include/media/tpg
diff options
context:
space:
mode:
authorPeilin Ye <yepeilin.cs@gmail.com>2020-08-21 17:13:43 +0200
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>2020-08-26 18:51:34 +0200
commit45c2044ccbedd48bc2a8cddde9ce7e82f03d588c (patch)
treeea7298df251c6cd3bec5e2a016093787b2c4a73b /include/media/tpg
parente3158a5e7e661786b3ab650c7e4d21024e8eff0f (diff)
downloadlinux-45c2044ccbedd48bc2a8cddde9ce7e82f03d588c.tar.gz
linux-45c2044ccbedd48bc2a8cddde9ce7e82f03d588c.tar.bz2
linux-45c2044ccbedd48bc2a8cddde9ce7e82f03d588c.zip
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 <hverkuil-cisco@xs4all.nl> Signed-off-by: Peilin Ye <yepeilin.cs@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'include/media/tpg')
-rw-r--r--include/media/tpg/v4l2-tpg.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/include/media/tpg/v4l2-tpg.h b/include/media/tpg/v4l2-tpg.h
index 0b0ddb87380e..181dcbe777f3 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;