linux/drivers/media/radio
Alexey Klimov 4b0cac5e75 [media] radio-mr800: move clamp_t check inside amradio_set_freq()
If i run verbose v4l2-compliance with my radio-mr800 device few times
then i get warning about frequency out of range:

root@machine:~# v4l2-compliance -r /dev/radio0 -v 2
is radio
Driver Info:
	Driver name   : radio-mr800
	Card type     : AverMedia MR 800 USB FM Radio
	Bus info      : usb-0000:00:1a.0-1.2
	Driver version: 3.9.0
	Capabilities  : 0x80050400
		Tuner
		Radio
		Device Capabilities
	Device Caps   : 0x00050400
		Tuner
		Radio
Compliance test for device /dev/radio0 (not using libv4l2):
Required ioctls:
	test VIDIOC_QUERYCAP: OK
Allow for multiple opens:
	test second radio open: OK
	test VIDIOC_QUERYCAP: OK
	test VIDIOC_G/S_PRIORITY: OK
Debug ioctls:
	test VIDIOC_DBG_G_CHIP_IDENT: OK (Not Supported)
	test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
	test VIDIOC_LOG_STATUS: OK
Input ioctls:
	test VIDIOC_G/S_TUNER: OK
		warn: v4l2-test-input-output.cpp(234): returned tuner 0 frequency out
of range (6550200 not in [1400000...1728000])
	test VIDIOC_G/S_FREQUENCY: OK
	test VIDIOC_S_HW_FREQ_SEEK: OK
	test VIDIOC_ENUMAUDIO: OK (Not Supported)
	test VIDIOC_G/S/ENUMINPUT: OK (Not Supported)
	test VIDIOC_G/S_AUDIO: OK (Not Supported)
	Inputs: 0 Audio Inputs: 0 Tuners: 1
Output ioctls:
	test VIDIOC_G/S_MODULATOR: OK (Not Supported)
	test VIDIOC_G/S_FREQUENCY: OK
	test VIDIOC_ENUMAUDOUT: OK (Not Supported)
	test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
	test VIDIOC_G/S_AUDOUT: OK (Not Supported)
	Outputs: 0 Audio Outputs: 0 Modulators: 0
Control ioctls:
		info: checking v4l2_queryctrl of control 'User Controls' (0x00980001)
		info: checking v4l2_queryctrl of control 'Mute' (0x00980909)
		info: checking v4l2_queryctrl of control 'Mute' (0x00980909)
	test VIDIOC_QUERYCTRL/MENU: OK
		info: checking control 'User Controls' (0x00980001)
		info: checking control 'Mute' (0x00980909)
	test VIDIOC_G/S_CTRL: OK
		info: checking extended control 'User Controls' (0x00980001)
		info: checking extended control 'Mute' (0x00980909)
	test VIDIOC_G/S/TRY_EXT_CTRLS: OK
		info: checking control event 'User Controls' (0x00980001)
		info: checking control event 'Mute' (0x00980909)
	test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
	test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
	Standard Controls: 2 Private Controls: 0
Input/Output configuration ioctls:
	test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
	test VIDIOC_ENUM/G/S/QUERY_DV_PRESETS: OK (Not Supported)
	test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
	test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
Format ioctls:
	test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK (Not Supported)
	test VIDIOC_G/S_PARM: OK (Not Supported)
	test VIDIOC_G_FBUF: OK (Not Supported)
	test VIDIOC_G_FMT: OK (Not Supported)
	test VIDIOC_TRY_FMT: OK (Not Supported)
	test VIDIOC_S_FMT: OK (Not Supported)
	test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
Codec ioctls:
	test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
	test VIDIOC_G_ENC_INDEX: OK (Not Supported)
	test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)
Buffer ioctls:
	test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK (Not Supported)
Total: 38, Succeeded: 38, Failed: 0, Warnings: 1

Some printk() debugging showed that vidioc_s_hw_freq_seek() setups
radio->curfreq to out of range value (lines 395-396) and calls
amradio_set_freq() to set this frequency on device without any
out-of-range checks.

Patch protects from setting up frequency on device to incorrect value
moving clamp_t check inside amradio_set_freq. With this patch we can
call amradio_set_freq() with out of range frequency from any place.
Also put comment that sometimes radio->curfreq is set to out of range
value in vidioc_s_hw_freq_seek().

Signed-off-by: Alexey Klimov <klimov.linux@gmail.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-03-29 08:20:19 -03:00
..
si470x [media] v4l2: add const to argument of write-only s_tuner ioctl 2013-03-24 06:31:23 -03:00
wl128x [media] v4l2: add const to argument of write-only s_tuner ioctl 2013-03-24 06:31:23 -03:00
dsbr100.c [media] v4l2: add const to argument of write-only s_tuner ioctl 2013-03-24 06:31:23 -03:00
Kconfig Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media 2013-02-24 17:35:10 -08:00
lm7000.h [media] radio: Add Sanyo LM7000 tuner driver 2012-06-25 11:07:27 -03:00
Makefile [media] media: add driver for Masterkit MA901 usb radio 2012-12-28 12:20:33 -02:00
radio-aimslab.c [media] radio-aimslab.c: get rid of warning: no previous prototype 2012-10-27 18:07:44 -02:00
radio-aztech.c [media] Add missing slab.h to fix linux-next compile errors 2012-03-19 11:25:12 -03:00
radio-cadet.c [media] v4l2: add const to argument of write-only s_tuner ioctl 2013-03-24 06:31:23 -03:00
radio-gemtek.c [media] radio-gemtek: add PnP support for AOpen FX-3D/Pro Radio 2012-04-10 19:53:19 -03:00
radio-isa.c [media] v4l2: add const to argument of write-only s_tuner ioctl 2013-03-24 06:31:23 -03:00
radio-isa.h [media] radio-isa: PnP support for the new ISA radio framework 2012-04-10 19:52:16 -03:00
radio-keene.c [media] v4l2: add const to argument of write-only s_frequency ioctl 2013-03-24 06:25:34 -03:00
radio-ma901.c [media] v4l2: add const to argument of write-only s_tuner ioctl 2013-03-24 06:31:23 -03:00
radio-maxiradio.c Drivers: media: remove __dev* attributes. 2013-01-03 15:57:02 -08:00
radio-miropcm20.c [media] v4l2: add const to argument of write-only s_tuner ioctl 2013-03-24 06:31:23 -03:00
radio-mr800.c [media] radio-mr800: move clamp_t check inside amradio_set_freq() 2013-03-29 08:20:19 -03:00
radio-rtrack2.c [media] radio-rtrack2: fix mute bug 2013-03-05 15:20:07 -03:00
radio-sf16fmi.c [media] v4l2: add const to argument of write-only s_tuner ioctl 2013-03-24 06:31:23 -03:00
radio-sf16fmr2.c Drivers: media: remove __dev* attributes. 2013-01-03 15:57:02 -08:00
radio-shark2.c [media] shark,shark2: declare resume/suspend functions as static 2012-09-13 17:42:13 -03:00
radio-shark.c [media] shark,shark2: declare resume/suspend functions as static 2012-09-13 17:42:13 -03:00
radio-si4713.c [media] ioctl numbers are unsigned int 2013-03-29 08:18:36 -03:00
radio-tea5764.c [media] v4l2: add const to argument of write-only s_tuner ioctl 2013-03-24 06:31:23 -03:00
radio-tea5777.c [media] v4l2: add const to argument of write-only s_tuner ioctl 2013-03-24 06:31:23 -03:00
radio-tea5777.h [media] radio-shark2: Add support for suspend & resume 2012-09-13 17:42:11 -03:00
radio-terratec.c [media] Add missing slab.h to fix linux-next compile errors 2012-03-19 11:25:12 -03:00
radio-timb.c [media] v4l2: add const to argument of write-only s_tuner ioctl 2013-03-24 06:31:23 -03:00
radio-trust.c [media] Add missing slab.h to fix linux-next compile errors 2012-03-19 11:25:12 -03:00
radio-typhoon.c [media] Add missing slab.h to fix linux-next compile errors 2012-03-19 11:25:12 -03:00
radio-wl1273.c [media] v4l2: add const to argument of write-only s_tuner ioctl 2013-03-24 06:31:23 -03:00
radio-zoltrix.c [media] Add missing slab.h to fix linux-next compile errors 2012-03-19 11:25:12 -03:00
saa7706h.c Drivers: media: remove __dev* attributes. 2013-01-03 15:57:02 -08:00
si4713-i2c.c [media] v4l2: add const to argument of write-only s_frequency ioctl 2013-03-24 06:25:34 -03:00
si4713-i2c.h [media] radio-si4713: Add regulator framework support 2010-12-29 08:16:35 -02:00
tef6862.c [media] v4l2: add const to argument of write-only s_tuner ioctl 2013-03-24 06:31:23 -03:00