linux/drivers
Jiri Slaby a38df1a013 TTY: pty, fix pty counting
commit 24d406a6bf upstream.

tty_operations->remove is normally called like:
queue_release_one_tty
 ->tty_shutdown
   ->tty_driver_remove_tty
     ->tty_operations->remove

However tty_shutdown() is called from queue_release_one_tty() only if
tty_operations->shutdown is NULL. But for pty, it is not.
pty_unix98_shutdown() is used there as ->shutdown.

So tty_operations->remove of pty (i.e. pty_unix98_remove()) is never
called. This results in invalid pty_count. I.e. what can be seen in
/proc/sys/kernel/pty/nr.

I see this was already reported at:
  https://lkml.org/lkml/2009/11/5/370
But it was not fixed since then.

This patch is kind of a hackish way. The problem lies in ->install. We
allocate there another tty (so-called tty->link). So ->install is
called once, but ->remove twice, for both tty and tty->link. The fix
here is to count both tty and tty->link and divide the count by 2 for
user.

And to have ->remove called, let's make tty_driver_remove_tty() global
and call that from pty_unix98_shutdown() (tty_operations->shutdown).

While at it, let's document that when ->shutdown is defined,
tty_shutdown() is not called.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Alan Cox <alan@linux.intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-10-03 11:39:49 -07:00
..
accessibility
acpi Merge branches 'd3cold', 'bugzilla-37412' and 'bugzilla-38152' into release 2011-07-14 00:16:38 -04:00
amba
ata ahci: change 'masking port_map' printk to KERN_WARNING level 2011-06-29 10:10:07 -07:00
atm
auxdisplay
base mm: Move definition of MIN_MEMORY_BLOCK_SIZE to a header 2011-07-12 11:08:01 +10:00
bcma
block xen-blkfront: Fix one off warning about name clash 2011-08-29 13:29:11 -07:00
bluetooth Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-2.6 into for-davem 2011-06-17 12:40:36 -04:00
cdrom
char net: Compute protocol sequence numbers and fragment IDs using MD5. 2011-08-15 18:31:35 -07:00
clk
clocksource
connector
cpufreq [CPUFREQ] fix cpumask memory leak in acpi-cpufreq on cpu hotplug. 2011-07-10 17:03:04 -04:00
cpuidle
crypto crypto: caam - fix operator precedence in shared descriptor allocation 2011-06-30 07:43:27 +08:00
dca
dio
dma
edac i7core_edac: fixed typo in error count calculation 2011-08-29 13:29:06 -07:00
eisa
firewire firewire: cdev: prevent race between first get_info ioctl and bus reset event queuing 2011-08-04 21:58:34 -07:00
firmware drivers/firmware/sigma.c needs MODULE_LICENSE 2011-08-04 21:58:38 -07:00
gpio gpio: wm831x: add a missing break in wm831x_gpio_dbg_show 2011-07-15 14:03:30 -06:00
gpu drm/radeon: Extended DDC Probing for Toshiba L300D Radeon Mobility X1100 HDMI-A Connector 2011-08-29 13:29:15 -07:00
hid HID: hid-multitouch: add support for a new Lumio dual-touch panel 2011-06-24 13:41:11 +02:00
hwmon hwmon: (ibmaem) add missing kfree 2011-08-17 10:55:53 -07:00
hwspinlock
i2c Merge branch 'for-30-rc5/all-i2c' of git://git.fluff.org/bjdooks/linux 2011-07-07 16:29:29 -07:00
ide
idle
ieee802154
infiniband IB/srp: Avoid duplicate devices from LUN scan 2011-08-04 21:58:34 -07:00
input input: pmic8xxx-pwrkey: Do not use mfd_get_data() 2011-07-05 10:38:43 +02:00
isdn net: Audit drivers to identify those needing IFF_TX_SKB_SHARING cleared 2011-08-15 18:31:38 -07:00
leds drivers/leds/leds-pca9532.c: change driver name to be unique 2011-07-08 21:14:44 -07:00
lguest
macintosh
mca
md dm: fix idr leak on module removal 2011-08-04 21:58:43 -07:00
media si4713-i2c: avoid potential buffer overflow on si4713 2011-07-18 09:12:21 -07:00
memstick
message
mfd w1: ds1wm: add a reset recovery parameter 2011-07-08 21:14:44 -07:00
misc geode: reflect mfgpt dependency on mfd 2011-08-04 21:58:38 -07:00
mmc mmc: sdhci: fix retuning timer wrongly deleted in sdhci_tasklet_finish 2011-08-29 13:29:16 -07:00
mtd powerpc/85xx: fix NAND_CMD_READID read bytes number 2011-06-22 06:08:48 -05:00
net rapidio: fix use of non-compatible registers 2011-10-03 11:39:46 -07:00
nfc
nubus
of
oprofile
parisc
parport
pci PCI: ARI is a PCIe v2 feature 2011-08-04 21:58:38 -07:00
pcmcia pcmcia: pxa2xx/vpac270: free gpios on exist rather than requesting 2011-07-11 14:26:34 +08:00
platform asus-wmi: return proper value in store_cpufv() 2011-08-15 18:31:35 -07:00
pnp
power
pps
ps3
ptp
rapidio rapidio: fix use of non-compatible registers 2011-10-03 11:39:46 -07:00
regulator regulator: max8997: Fix setting inappropriate value for ramp_delay variable 2011-07-08 19:14:58 +01:00
rtc drivers/rtc/rtc-tegra.c: properly initialize spinlock 2011-08-04 21:58:32 -07:00
s390
sbus
scsi mpt2sas: Fixed Big Indian Issues on 32 bit PPC 2011-08-15 18:31:39 -07:00
sfi
sh
sn
spi spi/s3c64xx: Bug fix for SPI with different FIFO level 2011-07-06 15:03:08 +09:00
ssb ssb: fix init regression of hostmode PCI core 2011-07-07 13:06:08 -04:00
staging staging: rtl8192u: declare MODULE_FIRMWARE 2011-08-17 10:55:50 -07:00
target tcm_fc: Fix conversion spec warning 2011-06-24 00:09:16 +00:00
tc
telephony
thermal
tty TTY: pty, fix pty counting 2011-10-03 11:39:49 -07:00
uio
usb USB: option driver: add PID for Vodafone-Huawei K4511 2011-08-17 10:55:52 -07:00
uwb
vhost
video vesafb: fix memory leak 2011-07-04 16:02:48 +09:00
virtio
vlynq
w1 w1: ds1wm: add a reset recovery parameter 2011-07-08 21:14:44 -07:00
watchdog watchdog: shwdt: fix usage of mod_timer 2011-08-04 21:58:42 -07:00
xen Merge branch 'stable/bug.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen 2011-06-20 09:01:33 -07:00
zorro
Kconfig
Makefile