aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/cec-funcs.h
diff options
context:
space:
mode:
authorHans Verkuil <hansverk@cisco.com>2016-07-06 04:49:26 -0400
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-07-08 17:34:42 -0400
commit0cb1f1e44cf5b013dd0991f509e332ac77ce2ddd (patch)
tree08356944be5b10d11a30eae971ae365bdba79c57 /include/linux/cec-funcs.h
parent5bb2399a4fe4a1703c1497b4838c5e8e869d0822 (diff)
[media] cec-funcs.h: add length checks
Add msg->len sanity checks to fix static checker warning: include/linux/cec-funcs.h:1154 cec_ops_set_osd_string() warn: setting length 'msg->len - 3' to negative one Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'include/linux/cec-funcs.h')
-rw-r--r--include/linux/cec-funcs.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/include/linux/cec-funcs.h b/include/linux/cec-funcs.h
index 19486009693a..8d217ce53034 100644
--- a/include/linux/cec-funcs.h
+++ b/include/linux/cec-funcs.h
@@ -788,7 +788,7 @@ static inline void cec_msg_set_timer_program_title(struct cec_msg *msg,
788static inline void cec_ops_set_timer_program_title(const struct cec_msg *msg, 788static inline void cec_ops_set_timer_program_title(const struct cec_msg *msg,
789 char *prog_title) 789 char *prog_title)
790{ 790{
791 unsigned int len = msg->len - 2; 791 unsigned int len = msg->len > 2 ? msg->len - 2 : 0;
792 792
793 if (len > 14) 793 if (len > 14)
794 len = 14; 794 len = 14;
@@ -1167,7 +1167,7 @@ static inline void cec_ops_set_osd_string(const struct cec_msg *msg,
1167 __u8 *disp_ctl, 1167 __u8 *disp_ctl,
1168 char *osd) 1168 char *osd)
1169{ 1169{
1170 unsigned int len = msg->len - 3; 1170 unsigned int len = msg->len > 3 ? msg->len - 3 : 0;
1171 1171
1172 *disp_ctl = msg->msg[2]; 1172 *disp_ctl = msg->msg[2];
1173 if (len > 13) 1173 if (len > 13)
@@ -1192,7 +1192,7 @@ static inline void cec_msg_set_osd_name(struct cec_msg *msg, const char *name)
1192static inline void cec_ops_set_osd_name(const struct cec_msg *msg, 1192static inline void cec_ops_set_osd_name(const struct cec_msg *msg,
1193 char *name) 1193 char *name)
1194{ 1194{
1195 unsigned int len = msg->len - 2; 1195 unsigned int len = msg->len > 2 ? msg->len - 2 : 0;
1196 1196
1197 if (len > 14) 1197 if (len > 14)
1198 len = 14; 1198 len = 14;