linux/drivers
Tejun Heo bf2253a6f0 cdrom: always check_disk_change() on open
cdrom_open() called check_disk_change() after the rest of open path
succeeded which leads to the following bizarre behavior.

* After media change, if the device opened without O_NONBLOCK,
  open_for_data() naturally fails with -ENOMEDIA and
  check_disk_change() is never called.  The media is known to be gone
  and the open failure makes it obvious to the userland but device
  invalidation never happens.

* But if the device is opened with O_NONBLOCK, all the checks are
  bypassed and cdrom_open() doesn't notice that the media is not there
  and check_disk_change() is called and invalidation happens.

There's nothing to be gained by avoiding calling check_disk_change()
on open failure.  Common cases end up calling check_disk_change()
anyway.  All we get is inconsistent behavior.

Fix it by moving check_disk_change() invocation to the top of
cdrom_open() so that it always gets called regardless of how the rest
of open proceeds.

Stable: 2.6.38

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Amit Shah <amit.shah@redhat.com>
Tested-by: Amit Shah <amit.shah@redhat.com>
Cc: stable@kernel.org
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
2011-04-29 10:17:25 +02:00
..
accessibility
acpi Fix common misspellings 2011-03-31 11:26:23 -03:00
amba PM / Hibernate: Introduce CONFIG_HIBERNATE_CALLBACKS 2011-04-11 22:54:42 +02:00
ata Fix common misspellings 2011-03-31 11:26:23 -03:00
atm Merge branch 'for-linus2' of git://git.profusion.mobi/users/lucas/linux-2.6 2011-04-07 11:14:49 -07:00
auxdisplay Fix common misspellings 2011-03-31 11:26:23 -03:00
base Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/suspend-2.6 2011-04-12 17:18:05 -07:00
block block: unexport DISK_EVENT_MEDIA_CHANGE for legacy/fringe drivers 2011-04-21 21:33:05 +02:00
bluetooth Merge branch 'for-linus2' of git://git.profusion.mobi/users/lucas/linux-2.6 2011-04-07 11:14:49 -07:00
cdrom cdrom: always check_disk_change() on open 2011-04-29 10:17:25 +02:00
char Merge git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus 2011-04-21 09:58:42 -07:00
clk
clocksource
connector connector: fix skb double free in cn_rx_skb() 2011-04-12 14:38:57 -07:00
cpufreq Fix common misspellings 2011-03-31 11:26:23 -03:00
cpuidle
crypto Fix common misspellings 2011-03-31 11:26:23 -03:00
dca drivers/dca/dca-core.c: use list_move() instead of list_del()/list_add() combination 2011-03-22 17:44:12 -07:00
dio
dma Merge branch 'spi/merge' of git://git.secretlab.ca/git/linux-2.6 2011-04-11 15:44:38 -07:00
edac Merge branch 'for-linus2' of git://git.profusion.mobi/users/lucas/linux-2.6 2011-04-07 11:14:49 -07:00
eisa
firewire Fix common misspellings 2011-03-31 11:26:23 -03:00
firmware sigma-firmware: loader for Analog Devices' SigmaStudio 2011-03-22 17:44:15 -07:00
gpio Merge branch 'spi/merge' of git://git.secretlab.ca/git/linux-2.6 2011-04-11 15:44:38 -07:00
gpu Merge branch 'drm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied/drm-2.6 2011-04-21 09:57:56 -07:00
hid Merge branch 'for-linus2' of git://git.profusion.mobi/users/lucas/linux-2.6 2011-04-07 11:14:49 -07:00
hwmon hwmon: (pmbus) Removed unused variable from struct pmbus_data 2011-04-19 08:49:56 -07:00
hwspinlock hwspinlock: depend on OMAP4 2011-03-18 17:15:11 -07:00
i2c i2c-algo-bit: Call pre/post_xfer for bit_test 2011-04-17 10:20:19 +02:00
ide ide: unexport DISK_EVENT_MEDIA_CHANGE for ide-gd and ide-cd 2011-04-21 19:43:59 +02:00
idle
ieee802154 ieee802154: change to new flag variable 2011-03-17 14:05:34 +01:00
infiniband Fix common misspellings 2011-03-31 11:26:23 -03:00
input Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2011-04-18 13:29:03 -07:00
isdn Fix common misspellings 2011-03-31 11:26:23 -03:00
leds leds/leds-regulator.c: fix handling of already enabled regulators 2011-04-14 16:06:54 -07:00
lguest Fix common misspellings 2011-03-31 11:26:23 -03:00
macintosh Merge branch 'for-linus2' of git://git.profusion.mobi/users/lucas/linux-2.6 2011-04-07 11:14:49 -07:00
mca
md raid5: fix build error, sector_t usage 2011-04-21 10:00:00 -07:00
media Revert "[media] V4L: videobuf, don't use dma addr as physical" 2011-04-19 10:54:44 -07:00
memstick Fix common misspellings 2011-03-31 11:26:23 -03:00
message block: unexport DISK_EVENT_MEDIA_CHANGE for legacy/fringe drivers 2011-04-21 21:33:05 +02:00
mfd mfd: Fetch cell pointer from platform_device->mfd_cell 2011-04-12 11:13:00 +02:00
misc drivers/misc/sgi-gru/grufile.c: fix the wrong members of gru_chip 2011-04-14 16:06:55 -07:00
mmc Fix common misspellings 2011-03-31 11:26:23 -03:00
mtd Merge git://git.infradead.org/mtd-2.6 2011-04-09 13:23:50 -07:00
net ip6_pol_route panic: Do not allow VLAN on loopback 2011-04-17 23:27:16 -07:00
nfc
nubus
of Fix common misspellings 2011-03-31 11:26:23 -03:00
oprofile
parisc Fix common misspellings 2011-03-31 11:26:23 -03:00
parport Fix common misspellings 2011-03-31 11:26:23 -03:00
pci Merge git://git.infradead.org/iommu-2.6 2011-04-21 09:56:35 -07:00
pcmcia ARM: pxa: convert incorrect IRQ_TO_IRQ() to irq_to_gpio() 2011-04-13 09:30:40 +08:00
platform Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mjg59/platform-drivers-x86 2011-04-13 09:15:55 -07:00
pnp Fix common misspellings 2011-03-31 11:26:23 -03:00
power drivers: Final irq namespace conversion 2011-03-29 14:48:19 +02:00
pps Fix common misspellings 2011-03-31 11:26:23 -03:00
ps3 Fix common misspellings 2011-03-31 11:26:23 -03:00
rapidio RapidIO/mpc85xx: fix possible mport registration problems 2011-04-14 16:06:56 -07:00
regulator Fix common misspellings 2011-03-31 11:26:23 -03:00
rtc RTC: rtc-omap: Fix a leak of the IRQ during init failure 2011-04-18 10:39:38 +02:00
s390 block: unexport DISK_EVENT_MEDIA_CHANGE for legacy/fringe drivers 2011-04-21 21:33:05 +02:00
sbus Fix common misspellings 2011-03-31 11:26:23 -03:00
scsi block: get rid of QUEUE_FLAG_REENTER 2011-04-19 13:32:46 +02:00
sfi Fix common misspellings 2011-03-31 11:26:23 -03:00
sh sh: Fix irq cleanup fallout 2011-03-30 00:15:49 +02:00
sn
spi Merge branch 'spi/merge' of git://git.secretlab.ca/git/linux-2.6 2011-04-11 15:44:38 -07:00
ssb Fix common misspellings 2011-03-31 11:26:23 -03:00
staging Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mjg59/platform-drivers-x86 2011-04-12 15:24:23 -07:00
target Fix common misspellings 2011-03-31 11:26:23 -03:00
tc
telephony Fix common misspellings 2011-03-31 11:26:23 -03:00
thermal
tty Merge branch 'sh-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6 2011-04-07 12:48:45 -07:00
uio Fix common misspellings 2011-03-31 11:26:23 -03:00
usb Revert "USB: isp1760-hcd: move imask clear after pending work is done" 2011-04-14 13:37:07 -07:00
uwb Fix common misspellings 2011-03-31 11:26:23 -03:00
vhost
video ARM: pxafb: Fix access to nonexistent member of pxafb_info 2011-04-12 23:07:42 +08:00
virtio virtio_pci: Prevent double-free of pci regions after device hot-unplug 2011-04-21 22:57:00 +09:30
vlynq vlynq: Convert irq functions 2011-03-28 19:33:04 +02:00
w1 Fix common misspellings 2011-03-31 11:26:23 -03:00
watchdog watchdog: mpc8xxx_wdt: fix build 2011-04-07 20:20:24 +00:00
xen Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/suspend-2.6 2011-04-12 17:18:05 -07:00
zorro
Kconfig
Makefile