aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/bt8xx/bttv-driver.c
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/bt8xx/bttv-driver.c
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/bt8xx/bttv-driver.c')
-rw-r--r--drivers/media/video/bt8xx/bttv-driver.c13
1 files changed, 5 insertions, 8 deletions
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