linux/drivers/media
Maciej Matraszek 3bacc10cd4 [media] v4l2-common: fix overflow in v4l_bound_align_image()
Fix clamp_align() used in v4l_bound_align_image() to prevent overflow
when passed large value like UINT32_MAX.

 In the current implementation:
    clamp_align(UINT32_MAX, 8, 8192, 3)

returns 8, because in line:

    x = (x + (1 << (align - 1))) & mask;

x overflows to (-1 + 4) & 0x7 = 3, while expected value is 8192.

v4l_bound_align_image() is heavily used in VIDIOC_S_FMT and
VIDIOC_SUBDEV_S_FMT ioctls handlers, and documentation of the latter
explicitly states that:

"The modified format should be as close as possible to the original
request."
  -- http://linuxtv.org/downloads/v4l-dvb-apis/vidioc-subdev-g-fmt.html

Thus one would expect, that passing UINT32_MAX as format width and
height will result in setting maximum possible resolution for the
device. Particularly, when the driver doesn't support
VIDIOC_ENUM_FRAMESIZES ioctl, which is common in the codebase.

Fixes changeset: b0d3159be9

Signed-off-by: Maciej Matraszek <m.matraszek@samsung.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-09-23 16:13:43 -03:00
..
common [media] drivers: media: b2c2: flexcop.h: Fix typo in include guard 2014-09-21 20:11:54 -03:00
dvb-core Merge remote-tracking branch 'linus/master' into patchwork 2014-09-21 16:40:04 -03:00
dvb-frontends [media] dvb: si21xx: buffer overflow in si21_writeregs() 2014-09-23 16:13:38 -03:00
firewire [media] firewire: firedtv-avc: fix more potential buffer overflow 2014-09-23 16:13:39 -03:00
i2c [media] adv7604/adv7842: fix il_vbackporch typo and zero the struct 2014-09-21 20:41:00 -03:00
mmc
parport [media] v4l: Support extending the v4l2_pix_format structure 2014-07-17 12:44:47 -03:00
pci [media] cx23885: fix size helper functions 2014-09-21 20:42:29 -03:00
platform [media] v4l: ti-vpe: Remove casting the return value which is a void pointer 2014-09-22 19:21:08 -03:00
radio [media] radio-si470x-usb: use USB API functions rather than constants 2014-09-21 20:10:33 -03:00
rc [media] mceusb: fix usbdev leak 2014-09-23 16:13:38 -03:00
tuners [media] si2157: Add support for Si2147-A30 tuner 2014-09-23 16:13:39 -03:00
usb [media] em28xx: remove dead code line from em28xx_audio_setup() 2014-09-23 16:13:42 -03:00
v4l2-core [media] v4l2-common: fix overflow in v4l_bound_align_image() 2014-09-23 16:13:43 -03:00
Kconfig [media] Kconfig: do not select SPI bus on sub-driver auto-select 2014-09-04 12:18:49 -03:00
Makefile
media-device.c [media] media: Use strlcpy instead of custom code 2014-09-21 20:27:08 -03:00
media-devnode.c [media] media-devnode: just return 0 instead of using a var 2014-09-03 17:59:28 -03:00
media-entity.c [media] media: Check for active links on pads with MEDIA_PAD_FL_MUST_CONNECT flag 2013-12-04 15:03:45 -02:00