aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video
diff options
context:
space:
mode:
authorTrent Piepho <xyzzy@speakeasy.org>2009-01-28 19:32:58 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:42:46 -0400
commit4ef2ccc2611456667ea78c6f418ce87e1fa9fac5 (patch)
treeedb8e2540969dfe6143cd75c35ed18d1937f74df /drivers/media/video
parent1d6af821a91df15e3fc2720c223ec514ae83dc86 (diff)
V4L/DVB (10558): bttv: norm value should be unsigned
The norm value in the driver is an index into an array and the the driver doesn't allow it to be negative or otherwise invalid. It should be unsigned but wasn't in all places. Fix some structs and functions to have the norm be unsigned. Get rid of useless checks for "< 0". Most of the driver code can't handle a norm value that's out of range, so change some ">= BTTV_TVNORMS" checks to BUG_ON(). There's no point in silently ignoring invalid driver state just to crash because of it later. Reported-by: Roel Kluin <roel.kluin@gmail.com> Signed-off-by: Trent Piepho <xyzzy@speakeasy.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video')
-rw-r--r--drivers/media/video/bt8xx/bttv-cards.c2
-rw-r--r--drivers/media/video/bt8xx/bttv-driver.c13
-rw-r--r--drivers/media/video/bt8xx/bttv-vbi.c2
-rw-r--r--drivers/media/video/bt8xx/bttv.h2
-rw-r--r--drivers/media/video/bt8xx/bttvp.h9
5 files changed, 13 insertions, 15 deletions
diff --git a/drivers/media/video/bt8xx/bttv-cards.c b/drivers/media/video/bt8xx/bttv-cards.c
index 9dfd8c70e4fb..2df0ce2afe98 100644
--- a/drivers/media/video/bt8xx/bttv-cards.c
+++ b/drivers/media/video/bt8xx/bttv-cards.c
@@ -4085,7 +4085,7 @@ static void __devinit avermedia_eeprom(struct bttv *btv)
4085} 4085}
4086 4086
4087/* used on Voodoo TV/FM (Voodoo 200), S0 wired to 0x10000 */ 4087/* used on Voodoo TV/FM (Voodoo 200), S0 wired to 0x10000 */
4088void bttv_tda9880_setnorm(struct bttv *btv, int norm) 4088void bttv_tda9880_setnorm(struct bttv *btv, unsigned int norm)
4089{ 4089{
4090 /* fix up our card entry */ 4090 /* fix up our card entry */
4091 if(norm==V4L2_STD_NTSC) { 4091 if(norm==V4L2_STD_NTSC) {
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index c71f394fc0ea..4ec476a9c0e4 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -1277,7 +1277,7 @@ bttv_crop_calc_limits(struct bttv_crop *c)
1277} 1277}
1278 1278
1279static void 1279static void
1280bttv_crop_reset(struct bttv_crop *c, int norm) 1280bttv_crop_reset(struct bttv_crop *c, unsigned int norm)
1281{ 1281{
1282 c->rect = bttv_tvnorms[norm].cropcap.defrect; 1282 c->rect = bttv_tvnorms[norm].cropcap.defrect;
1283 bttv_crop_calc_limits(c); 1283 bttv_crop_calc_limits(c);
@@ -1290,16 +1290,13 @@ set_tvnorm(struct bttv *btv, unsigned int norm)
1290 const struct bttv_tvnorm *tvnorm; 1290 const struct bttv_tvnorm *tvnorm;
1291 v4l2_std_id id; 1291 v4l2_std_id id;
1292 1292
1293 if (norm < 0 || norm >= BTTV_TVNORMS) 1293 BUG_ON(norm >= BTTV_TVNORMS);
1294 return -EINVAL; 1294 BUG_ON(btv->tvnorm >= BTTV_TVNORMS);
1295 1295
1296 tvnorm = &bttv_tvnorms[norm]; 1296 tvnorm = &bttv_tvnorms[norm];
1297 1297
1298 if (btv->tvnorm < 0 || 1298 if (!memcmp(&bttv_tvnorms[btv->tvnorm].cropcap, &tvnorm->cropcap,
1299 btv->tvnorm >= BTTV_TVNORMS || 1299 sizeof (tvnorm->cropcap))) {
1300 0 != memcmp(&bttv_tvnorms[btv->tvnorm].cropcap,
1301 &tvnorm->cropcap,
1302 sizeof (tvnorm->cropcap))) {
1303 bttv_crop_reset(&btv->crop[0], norm); 1300 bttv_crop_reset(&btv->crop[0], norm);
1304 btv->crop[1] = btv->crop[0]; /* current = default */ 1301 btv->crop[1] = btv->crop[0]; /* current = default */
1305 1302
diff --git a/drivers/media/video/bt8xx/bttv-vbi.c b/drivers/media/video/bt8xx/bttv-vbi.c
index 6819e21a3773..e79a402fa6cd 100644
--- a/drivers/media/video/bt8xx/bttv-vbi.c
+++ b/drivers/media/video/bt8xx/bttv-vbi.c
@@ -411,7 +411,7 @@ int bttv_g_fmt_vbi_cap(struct file *file, void *f, struct v4l2_format *frt)
411 return 0; 411 return 0;
412} 412}
413 413
414void bttv_vbi_fmt_reset(struct bttv_vbi_fmt *f, int norm) 414void bttv_vbi_fmt_reset(struct bttv_vbi_fmt *f, unsigned int norm)
415{ 415{
416 const struct bttv_tvnorm *tvnorm; 416 const struct bttv_tvnorm *tvnorm;
417 unsigned int real_samples_per_line; 417 unsigned int real_samples_per_line;
diff --git a/drivers/media/video/bt8xx/bttv.h b/drivers/media/video/bt8xx/bttv.h
index a7bcad171823..b1986b94d29f 100644
--- a/drivers/media/video/bt8xx/bttv.h
+++ b/drivers/media/video/bt8xx/bttv.h
@@ -265,7 +265,7 @@ extern void bttv_init_card2(struct bttv *btv);
265 265
266/* card-specific funtions */ 266/* card-specific funtions */
267extern void tea5757_set_freq(struct bttv *btv, unsigned short freq); 267extern void tea5757_set_freq(struct bttv *btv, unsigned short freq);
268extern void bttv_tda9880_setnorm(struct bttv *btv, int norm); 268extern void bttv_tda9880_setnorm(struct bttv *btv, unsigned int norm);
269 269
270/* extra tweaks for some chipsets */ 270/* extra tweaks for some chipsets */
271extern void bttv_check_chipset(void); 271extern void bttv_check_chipset(void);
diff --git a/drivers/media/video/bt8xx/bttvp.h b/drivers/media/video/bt8xx/bttvp.h
index 199a4d225caf..230e148e78fe 100644
--- a/drivers/media/video/bt8xx/bttvp.h
+++ b/drivers/media/video/bt8xx/bttvp.h
@@ -135,7 +135,7 @@ struct bttv_buffer {
135 135
136 /* bttv specific */ 136 /* bttv specific */
137 const struct bttv_format *fmt; 137 const struct bttv_format *fmt;
138 int tvnorm; 138 unsigned int tvnorm;
139 int btformat; 139 int btformat;
140 int btswap; 140 int btswap;
141 struct bttv_geometry geo; 141 struct bttv_geometry geo;
@@ -154,7 +154,7 @@ struct bttv_buffer_set {
154}; 154};
155 155
156struct bttv_overlay { 156struct bttv_overlay {
157 int tvnorm; 157 unsigned int tvnorm;
158 struct v4l2_rect w; 158 struct v4l2_rect w;
159 enum v4l2_field field; 159 enum v4l2_field field;
160 struct v4l2_clip *clips; 160 struct v4l2_clip *clips;
@@ -174,7 +174,7 @@ struct bttv_vbi_fmt {
174}; 174};
175 175
176/* bttv-vbi.c */ 176/* bttv-vbi.c */
177void bttv_vbi_fmt_reset(struct bttv_vbi_fmt *f, int norm); 177void bttv_vbi_fmt_reset(struct bttv_vbi_fmt *f, unsigned int norm);
178 178
179struct bttv_crop { 179struct bttv_crop {
180 /* A cropping rectangle in struct bttv_tvnorm.cropcap units. */ 180 /* A cropping rectangle in struct bttv_tvnorm.cropcap units. */
@@ -378,7 +378,8 @@ struct bttv {
378 unsigned int audio; 378 unsigned int audio;
379 unsigned int mute; 379 unsigned int mute;
380 unsigned long freq; 380 unsigned long freq;
381 int tvnorm,hue,contrast,bright,saturation; 381 unsigned int tvnorm;
382 int hue, contrast, bright, saturation;
382 struct v4l2_framebuffer fbuf; 383 struct v4l2_framebuffer fbuf;
383 unsigned int field_count; 384 unsigned int field_count;
384 385