aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2009-11-27 02:33:25 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-12-15 21:17:53 -0500
commita3a9e287daa1f299e318161b790b1c5902b1d869 (patch)
tree1f20db447f28a6346ce9d9fe2ebb0ff3eac65f96 /drivers/media
parentcda4303f555316930a219cd7c03a1925526145f0 (diff)
V4L/DVB (13547): radio: add trivial checks on the tuner and type args.
Many radio drivers did not check the tuner and type field correctly for g/s_frequency. These checks have now been added. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/radio/radio-aimslab.c4
-rw-r--r--drivers/media/radio/radio-aztech.c4
-rw-r--r--drivers/media/radio/radio-gemtek-pci.c4
-rw-r--r--drivers/media/radio/radio-maestro.c4
-rw-r--r--drivers/media/radio/radio-maxiradio.c4
-rw-r--r--drivers/media/radio/radio-mr800.c4
-rw-r--r--drivers/media/radio/radio-rtrack2.c4
-rw-r--r--drivers/media/radio/radio-sf16fmi.c4
-rw-r--r--drivers/media/radio/radio-sf16fmr2.c4
-rw-r--r--drivers/media/radio/radio-tea5764.c4
-rw-r--r--drivers/media/radio/radio-terratec.c4
-rw-r--r--drivers/media/radio/radio-trust.c4
-rw-r--r--drivers/media/radio/radio-typhoon.c4
-rw-r--r--drivers/media/radio/radio-zoltrix.c4
14 files changed, 55 insertions, 1 deletions
diff --git a/drivers/media/radio/radio-aimslab.c b/drivers/media/radio/radio-aimslab.c
index 35edee009ba8..5bf4985daede 100644
--- a/drivers/media/radio/radio-aimslab.c
+++ b/drivers/media/radio/radio-aimslab.c
@@ -268,6 +268,8 @@ static int vidioc_s_frequency(struct file *file, void *priv,
268{ 268{
269 struct rtrack *rt = video_drvdata(file); 269 struct rtrack *rt = video_drvdata(file);
270 270
271 if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
272 return -EINVAL;
271 rt_setfreq(rt, f->frequency); 273 rt_setfreq(rt, f->frequency);
272 return 0; 274 return 0;
273} 275}
@@ -277,6 +279,8 @@ static int vidioc_g_frequency(struct file *file, void *priv,
277{ 279{
278 struct rtrack *rt = video_drvdata(file); 280 struct rtrack *rt = video_drvdata(file);
279 281
282 if (f->tuner != 0)
283 return -EINVAL;
280 f->type = V4L2_TUNER_RADIO; 284 f->type = V4L2_TUNER_RADIO;
281 f->frequency = rt->curfreq; 285 f->frequency = rt->curfreq;
282 return 0; 286 return 0;
diff --git a/drivers/media/radio/radio-aztech.c b/drivers/media/radio/radio-aztech.c
index 8daf809eb01a..c22311393624 100644
--- a/drivers/media/radio/radio-aztech.c
+++ b/drivers/media/radio/radio-aztech.c
@@ -254,6 +254,8 @@ static int vidioc_s_frequency(struct file *file, void *priv,
254{ 254{
255 struct aztech *az = video_drvdata(file); 255 struct aztech *az = video_drvdata(file);
256 256
257 if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
258 return -EINVAL;
257 az_setfreq(az, f->frequency); 259 az_setfreq(az, f->frequency);
258 return 0; 260 return 0;
259} 261}
@@ -263,6 +265,8 @@ static int vidioc_g_frequency(struct file *file, void *priv,
263{ 265{
264 struct aztech *az = video_drvdata(file); 266 struct aztech *az = video_drvdata(file);
265 267
268 if (f->tuner != 0)
269 return -EINVAL;
266 f->type = V4L2_TUNER_RADIO; 270 f->type = V4L2_TUNER_RADIO;
267 f->frequency = az->curfreq; 271 f->frequency = az->curfreq;
268 return 0; 272 return 0;
diff --git a/drivers/media/radio/radio-gemtek-pci.c b/drivers/media/radio/radio-gemtek-pci.c
index c6cf11661868..000f4d34087c 100644
--- a/drivers/media/radio/radio-gemtek-pci.c
+++ b/drivers/media/radio/radio-gemtek-pci.c
@@ -240,6 +240,8 @@ static int vidioc_s_frequency(struct file *file, void *priv,
240{ 240{
241 struct gemtek_pci *card = video_drvdata(file); 241 struct gemtek_pci *card = video_drvdata(file);
242 242
243 if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
244 return -EINVAL;
243 if (f->frequency < GEMTEK_PCI_RANGE_LOW || 245 if (f->frequency < GEMTEK_PCI_RANGE_LOW ||
244 f->frequency > GEMTEK_PCI_RANGE_HIGH) 246 f->frequency > GEMTEK_PCI_RANGE_HIGH)
245 return -EINVAL; 247 return -EINVAL;
@@ -253,6 +255,8 @@ static int vidioc_g_frequency(struct file *file, void *priv,
253{ 255{
254 struct gemtek_pci *card = video_drvdata(file); 256 struct gemtek_pci *card = video_drvdata(file);
255 257
258 if (f->tuner != 0)
259 return -EINVAL;
256 f->type = V4L2_TUNER_RADIO; 260 f->type = V4L2_TUNER_RADIO;
257 f->frequency = card->current_frequency; 261 f->frequency = card->current_frequency;
258 return 0; 262 return 0;
diff --git a/drivers/media/radio/radio-maestro.c b/drivers/media/radio/radio-maestro.c
index 64d737c35acf..f8213b7c8ddc 100644
--- a/drivers/media/radio/radio-maestro.c
+++ b/drivers/media/radio/radio-maestro.c
@@ -200,6 +200,8 @@ static int vidioc_s_frequency(struct file *file, void *priv,
200{ 200{
201 struct maestro *dev = video_drvdata(file); 201 struct maestro *dev = video_drvdata(file);
202 202
203 if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
204 return -EINVAL;
203 if (f->frequency < FREQ_LO || f->frequency > FREQ_HI) 205 if (f->frequency < FREQ_LO || f->frequency > FREQ_HI)
204 return -EINVAL; 206 return -EINVAL;
205 mutex_lock(&dev->lock); 207 mutex_lock(&dev->lock);
@@ -213,6 +215,8 @@ static int vidioc_g_frequency(struct file *file, void *priv,
213{ 215{
214 struct maestro *dev = video_drvdata(file); 216 struct maestro *dev = video_drvdata(file);
215 217
218 if (f->tuner != 0)
219 return -EINVAL;
216 f->type = V4L2_TUNER_RADIO; 220 f->type = V4L2_TUNER_RADIO;
217 mutex_lock(&dev->lock); 221 mutex_lock(&dev->lock);
218 f->frequency = BITS2FREQ(radio_bits_get(dev)); 222 f->frequency = BITS2FREQ(radio_bits_get(dev));
diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
index 3da51fe8fb93..44b4dbedb322 100644
--- a/drivers/media/radio/radio-maxiradio.c
+++ b/drivers/media/radio/radio-maxiradio.c
@@ -262,6 +262,8 @@ static int vidioc_s_frequency(struct file *file, void *priv,
262{ 262{
263 struct maxiradio *dev = video_drvdata(file); 263 struct maxiradio *dev = video_drvdata(file);
264 264
265 if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
266 return -EINVAL;
265 if (f->frequency < FREQ_LO || f->frequency > FREQ_HI) { 267 if (f->frequency < FREQ_LO || f->frequency > FREQ_HI) {
266 dprintk(dev, 1, "radio freq (%d.%02d MHz) out of range (%d-%d)\n", 268 dprintk(dev, 1, "radio freq (%d.%02d MHz) out of range (%d-%d)\n",
267 f->frequency / 16000, 269 f->frequency / 16000,
@@ -285,6 +287,8 @@ static int vidioc_g_frequency(struct file *file, void *priv,
285{ 287{
286 struct maxiradio *dev = video_drvdata(file); 288 struct maxiradio *dev = video_drvdata(file);
287 289
290 if (f->tuner != 0)
291 return -EINVAL;
288 f->type = V4L2_TUNER_RADIO; 292 f->type = V4L2_TUNER_RADIO;
289 f->frequency = dev->freq; 293 f->frequency = dev->freq;
290 294
diff --git a/drivers/media/radio/radio-mr800.c b/drivers/media/radio/radio-mr800.c
index 949f60513d9e..02a9cefc9a00 100644
--- a/drivers/media/radio/radio-mr800.c
+++ b/drivers/media/radio/radio-mr800.c
@@ -374,6 +374,8 @@ static int vidioc_s_frequency(struct file *file, void *priv,
374{ 374{
375 struct amradio_device *radio = file->private_data; 375 struct amradio_device *radio = file->private_data;
376 376
377 if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
378 return -EINVAL;
377 return amradio_setfreq(radio, f->frequency); 379 return amradio_setfreq(radio, f->frequency);
378} 380}
379 381
@@ -383,6 +385,8 @@ static int vidioc_g_frequency(struct file *file, void *priv,
383{ 385{
384 struct amradio_device *radio = file->private_data; 386 struct amradio_device *radio = file->private_data;
385 387
388 if (f->tuner != 0)
389 return -EINVAL;
386 f->type = V4L2_TUNER_RADIO; 390 f->type = V4L2_TUNER_RADIO;
387 f->frequency = radio->curfreq; 391 f->frequency = radio->curfreq;
388 392
diff --git a/drivers/media/radio/radio-rtrack2.c b/drivers/media/radio/radio-rtrack2.c
index 9cb193fa6e33..a79296aac9a9 100644
--- a/drivers/media/radio/radio-rtrack2.c
+++ b/drivers/media/radio/radio-rtrack2.c
@@ -167,6 +167,8 @@ static int vidioc_s_frequency(struct file *file, void *priv,
167{ 167{
168 struct rtrack2 *rt = video_drvdata(file); 168 struct rtrack2 *rt = video_drvdata(file);
169 169
170 if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
171 return -EINVAL;
170 rt_setfreq(rt, f->frequency); 172 rt_setfreq(rt, f->frequency);
171 return 0; 173 return 0;
172} 174}
@@ -176,6 +178,8 @@ static int vidioc_g_frequency(struct file *file, void *priv,
176{ 178{
177 struct rtrack2 *rt = video_drvdata(file); 179 struct rtrack2 *rt = video_drvdata(file);
178 180
181 if (f->tuner != 0)
182 return -EINVAL;
179 f->type = V4L2_TUNER_RADIO; 183 f->type = V4L2_TUNER_RADIO;
180 f->frequency = rt->curfreq; 184 f->frequency = rt->curfreq;
181 return 0; 185 return 0;
diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c
index 49c4aab95dab..93990b7899ec 100644
--- a/drivers/media/radio/radio-sf16fmi.c
+++ b/drivers/media/radio/radio-sf16fmi.c
@@ -168,6 +168,8 @@ static int vidioc_s_frequency(struct file *file, void *priv,
168{ 168{
169 struct fmi *fmi = video_drvdata(file); 169 struct fmi *fmi = video_drvdata(file);
170 170
171 if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
172 return -EINVAL;
171 if (f->frequency < RSF16_MINFREQ || 173 if (f->frequency < RSF16_MINFREQ ||
172 f->frequency > RSF16_MAXFREQ) 174 f->frequency > RSF16_MAXFREQ)
173 return -EINVAL; 175 return -EINVAL;
@@ -182,6 +184,8 @@ static int vidioc_g_frequency(struct file *file, void *priv,
182{ 184{
183 struct fmi *fmi = video_drvdata(file); 185 struct fmi *fmi = video_drvdata(file);
184 186
187 if (f->tuner != 0)
188 return -EINVAL;
185 f->type = V4L2_TUNER_RADIO; 189 f->type = V4L2_TUNER_RADIO;
186 f->frequency = fmi->curfreq; 190 f->frequency = fmi->curfreq;
187 return 0; 191 return 0;
diff --git a/drivers/media/radio/radio-sf16fmr2.c b/drivers/media/radio/radio-sf16fmr2.c
index a11414f648d4..52c7bbb32b8b 100644
--- a/drivers/media/radio/radio-sf16fmr2.c
+++ b/drivers/media/radio/radio-sf16fmr2.c
@@ -251,6 +251,8 @@ static int vidioc_s_frequency(struct file *file, void *priv,
251{ 251{
252 struct fmr2 *fmr2 = video_drvdata(file); 252 struct fmr2 *fmr2 = video_drvdata(file);
253 253
254 if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
255 return -EINVAL;
254 if (f->frequency < RSF16_MINFREQ || 256 if (f->frequency < RSF16_MINFREQ ||
255 f->frequency > RSF16_MAXFREQ) 257 f->frequency > RSF16_MAXFREQ)
256 return -EINVAL; 258 return -EINVAL;
@@ -272,6 +274,8 @@ static int vidioc_g_frequency(struct file *file, void *priv,
272{ 274{
273 struct fmr2 *fmr2 = video_drvdata(file); 275 struct fmr2 *fmr2 = video_drvdata(file);
274 276
277 if (f->tuner != 0)
278 return -EINVAL;
275 f->type = V4L2_TUNER_RADIO; 279 f->type = V4L2_TUNER_RADIO;
276 f->frequency = fmr2->curfreq; 280 f->frequency = fmr2->curfreq;
277 return 0; 281 return 0;
diff --git a/drivers/media/radio/radio-tea5764.c b/drivers/media/radio/radio-tea5764.c
index 3cd76dddb6aa..730ffd9cdd3e 100644
--- a/drivers/media/radio/radio-tea5764.c
+++ b/drivers/media/radio/radio-tea5764.c
@@ -349,7 +349,7 @@ static int vidioc_s_frequency(struct file *file, void *priv,
349{ 349{
350 struct tea5764_device *radio = video_drvdata(file); 350 struct tea5764_device *radio = video_drvdata(file);
351 351
352 if (f->tuner != 0) 352 if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
353 return -EINVAL; 353 return -EINVAL;
354 if (f->frequency == 0) { 354 if (f->frequency == 0) {
355 /* We special case this as a power down control. */ 355 /* We special case this as a power down control. */
@@ -370,6 +370,8 @@ static int vidioc_g_frequency(struct file *file, void *priv,
370 struct tea5764_device *radio = video_drvdata(file); 370 struct tea5764_device *radio = video_drvdata(file);
371 struct tea5764_regs *r = &radio->regs; 371 struct tea5764_regs *r = &radio->regs;
372 372
373 if (f->tuner != 0)
374 return -EINVAL;
373 tea5764_i2c_read(radio); 375 tea5764_i2c_read(radio);
374 memset(f, 0, sizeof(f)); 376 memset(f, 0, sizeof(f));
375 f->type = V4L2_TUNER_RADIO; 377 f->type = V4L2_TUNER_RADIO;
diff --git a/drivers/media/radio/radio-terratec.c b/drivers/media/radio/radio-terratec.c
index 699db9acaaf7..fc1c860fd438 100644
--- a/drivers/media/radio/radio-terratec.c
+++ b/drivers/media/radio/radio-terratec.c
@@ -240,6 +240,8 @@ static int vidioc_s_frequency(struct file *file, void *priv,
240{ 240{
241 struct terratec *tt = video_drvdata(file); 241 struct terratec *tt = video_drvdata(file);
242 242
243 if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
244 return -EINVAL;
243 tt_setfreq(tt, f->frequency); 245 tt_setfreq(tt, f->frequency);
244 return 0; 246 return 0;
245} 247}
@@ -249,6 +251,8 @@ static int vidioc_g_frequency(struct file *file, void *priv,
249{ 251{
250 struct terratec *tt = video_drvdata(file); 252 struct terratec *tt = video_drvdata(file);
251 253
254 if (f->tuner != 0)
255 return -EINVAL;
252 f->type = V4L2_TUNER_RADIO; 256 f->type = V4L2_TUNER_RADIO;
253 f->frequency = tt->curfreq; 257 f->frequency = tt->curfreq;
254 return 0; 258 return 0;
diff --git a/drivers/media/radio/radio-trust.c b/drivers/media/radio/radio-trust.c
index 6f9ecc359356..9d6dcf8af5b0 100644
--- a/drivers/media/radio/radio-trust.c
+++ b/drivers/media/radio/radio-trust.c
@@ -239,6 +239,8 @@ static int vidioc_s_frequency(struct file *file, void *priv,
239{ 239{
240 struct trust *tr = video_drvdata(file); 240 struct trust *tr = video_drvdata(file);
241 241
242 if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
243 return -EINVAL;
242 tr_setfreq(tr, f->frequency); 244 tr_setfreq(tr, f->frequency);
243 return 0; 245 return 0;
244} 246}
@@ -248,6 +250,8 @@ static int vidioc_g_frequency(struct file *file, void *priv,
248{ 250{
249 struct trust *tr = video_drvdata(file); 251 struct trust *tr = video_drvdata(file);
250 252
253 if (f->tuner != 0)
254 return -EINVAL;
251 f->type = V4L2_TUNER_RADIO; 255 f->type = V4L2_TUNER_RADIO;
252 f->frequency = tr->curfreq; 256 f->frequency = tr->curfreq;
253 return 0; 257 return 0;
diff --git a/drivers/media/radio/radio-typhoon.c b/drivers/media/radio/radio-typhoon.c
index 3a98f1399495..03439282dfce 100644
--- a/drivers/media/radio/radio-typhoon.c
+++ b/drivers/media/radio/radio-typhoon.c
@@ -207,6 +207,8 @@ static int vidioc_g_frequency(struct file *file, void *priv,
207{ 207{
208 struct typhoon *dev = video_drvdata(file); 208 struct typhoon *dev = video_drvdata(file);
209 209
210 if (f->tuner != 0)
211 return -EINVAL;
210 f->type = V4L2_TUNER_RADIO; 212 f->type = V4L2_TUNER_RADIO;
211 f->frequency = dev->curfreq; 213 f->frequency = dev->curfreq;
212 return 0; 214 return 0;
@@ -217,6 +219,8 @@ static int vidioc_s_frequency(struct file *file, void *priv,
217{ 219{
218 struct typhoon *dev = video_drvdata(file); 220 struct typhoon *dev = video_drvdata(file);
219 221
222 if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
223 return -EINVAL;
220 dev->curfreq = f->frequency; 224 dev->curfreq = f->frequency;
221 typhoon_setfreq(dev, dev->curfreq); 225 typhoon_setfreq(dev, dev->curfreq);
222 return 0; 226 return 0;
diff --git a/drivers/media/radio/radio-zoltrix.c b/drivers/media/radio/radio-zoltrix.c
index 80e98b6422fe..f31eab99c943 100644
--- a/drivers/media/radio/radio-zoltrix.c
+++ b/drivers/media/radio/radio-zoltrix.c
@@ -266,6 +266,8 @@ static int vidioc_s_frequency(struct file *file, void *priv,
266{ 266{
267 struct zoltrix *zol = video_drvdata(file); 267 struct zoltrix *zol = video_drvdata(file);
268 268
269 if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
270 return -EINVAL;
269 if (zol_setfreq(zol, f->frequency) != 0) 271 if (zol_setfreq(zol, f->frequency) != 0)
270 return -EINVAL; 272 return -EINVAL;
271 return 0; 273 return 0;
@@ -276,6 +278,8 @@ static int vidioc_g_frequency(struct file *file, void *priv,
276{ 278{
277 struct zoltrix *zol = video_drvdata(file); 279 struct zoltrix *zol = video_drvdata(file);
278 280
281 if (f->tuner != 0)
282 return -EINVAL;
279 f->type = V4L2_TUNER_RADIO; 283 f->type = V4L2_TUNER_RADIO;
280 f->frequency = zol->curfreq; 284 f->frequency = zol->curfreq;
281 return 0; 285 return 0;