kernel_optimize_test/drivers/media
Tuukka Toivonen 47b037a051 [media] v4l2-async: failing functions shouldn't have side effects
v4l2-async had several functions doing some operations and then
not undoing the operations in a failure situation. For example,
v4l2_async_test_notify() moved a subdev into notifier's done list
even if registering the subdev (v4l2_device_register_subdev) failed.
If the subdev was allocated and v4l2_async_register_subdev() called
from the driver's probe() function, as usually, the probe()
function freed the allocated subdev and returned a failure.
Nevertheless, the subdev was still left into the notifier's done
list, causing an access to already freed memory when the notifier
was later unregistered.

A hand-edited call trace leaving freed subdevs into the notifier:

v4l2_async_register_notifier(notifier, asd)
cameradrv_probe
 sd = devm_kzalloc()
 v4l2_async_register_subdev(sd)
  v4l2_async_test_notify(notifier, sd, asd)
   list_move(sd, &notifier->done)
   v4l2_device_register_subdev(notifier->v4l2_dev, sd)
    cameradrv_registered(sd) -> fails
->v4l2_async_register_subdev returns failure
->cameradrv_probe returns failure
->devres frees the allocated sd
->sd was freed but it still remains in the notifier's list.

This patch fixes this and several other cases where a failing
function could leave nodes into a linked list while the caller
might free the node due to a failure.

Signed-off-by: Tuukka Toivonen <tuukka.toivonen@intel.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-02-03 14:51:56 -02:00
..
cec [media] rc-main: assign driver type during allocation 2017-01-30 13:59:57 -02:00
common [media] b2c2: use IS_REACHABLE() instead of open-coding it 2017-02-03 07:12:59 -02:00
dvb-core [media] media: dvb: dmx: fixed coding style issues of spacing 2017-02-03 11:35:10 -02:00
dvb-frontends [media] media: dvb-frontends: constify vb2_ops structure 2017-02-03 14:23:39 -02:00
firewire [media] firewire: don't break long lines 2016-10-21 10:06:00 -02:00
i2c [media] tc358743: ctrl_detect_tx_5v should always be updated 2017-02-03 11:16:25 -02:00
mmc
pci [media] mantis_dvb: fix some error codes in mantis_dvb_init() 2017-02-03 14:50:35 -02:00
platform [media] exynos-gsc: Avoid spamming the log on VIDIOC_TRY_FMT 2017-02-03 14:26:35 -02:00
radio [media] media: radio-cadet, initialize timer with setup_timer 2017-02-03 11:23:51 -02:00
rc [media] mce_kbd: add missing keys from UK layout 2017-02-03 14:23:37 -02:00
spi [media] gs1662: drop kfree for memory allocated with devm_kzalloc 2016-10-24 17:59:08 -02:00
tuners [media] mt2060: implement sleep 2017-02-03 06:55:46 -02:00
usb [media] dvb-usb: don't use stack for firmware load 2017-02-03 14:23:41 -02:00
v4l2-core [media] v4l2-async: failing functions shouldn't have side effects 2017-02-03 14:51:56 -02:00
cec-edid.c
Kconfig [media] Kconfig: fix breakages when DVB_CORE is not selected 2016-11-18 17:59:17 -02:00
Makefile [media] cec: move the CEC framework out of staging and to media 2016-11-16 15:40:20 -02:00
media-device.c [media] media: Rename graph and pipeline structs and functions 2017-01-27 16:13:24 -02:00
media-devnode.c [media] media: Drop FSF's postal address from the source code files 2017-01-27 11:38:09 -02:00
media-entity.c [media] media: entity: Add debug information to graph walk 2017-01-30 11:33:26 -02:00