<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/drivers, branch v2.6.16.53</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>ide: clear bmdma status in ide_intr() for ICHx controllers (revised #4)</title>
<updated>2007-07-22T16:05:44+00:00</updated>
<author>
<name>Albert Lee</name>
<email>albertcc@tw.ibm.com</email>
</author>
<published>2007-07-22T16:05:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=4de632544dbaeabafba6aa42e9a1971ec8eeb022'/>
<id>4de632544dbaeabafba6aa42e9a1971ec8eeb022</id>
<content type='text'>
patch 1/2 (revised):
- Fix drive-&gt;waiting_for_dma to work with CDB-intr devices.
- Do the dma status clearing in ide_intr() and add a new
  hwif-&gt;ide_dma_clear_irq for Intel ICHx controllers.

Revised per Alan, Sergei and Bart's advice.

Patch against 2.6.20-rc6. Tested ok on my ICH4 and pdc20275 adapters.
Please review/apply, thanks.

Signed-off-by: Albert Lee &lt;albertcc@tw.ibm.com&gt;
Signed-off-by: Adrian Bunk &lt;bunk@stusta.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
patch 1/2 (revised):
- Fix drive-&gt;waiting_for_dma to work with CDB-intr devices.
- Do the dma status clearing in ide_intr() and add a new
  hwif-&gt;ide_dma_clear_irq for Intel ICHx controllers.

Revised per Alan, Sergei and Bart's advice.

Patch against 2.6.20-rc6. Tested ok on my ICH4 and pdc20275 adapters.
Please review/apply, thanks.

Signed-off-by: Albert Lee &lt;albertcc@tw.ibm.com&gt;
Signed-off-by: Adrian Bunk &lt;bunk@stusta.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>8139too.c: fix netpoll deadlock</title>
<updated>2007-07-22T16:03:53+00:00</updated>
<author>
<name>Ingo Molnar</name>
<email>mingo@elte.hu</email>
</author>
<published>2007-07-22T16:03:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=8b9320927b5a4f7b506609d8c0aded13550e42a7'/>
<id>8b9320927b5a4f7b506609d8c0aded13550e42a7</id>
<content type='text'>
fix deadlock in the 8139too driver: poll handlers should never forcibly
enable local interrupts, because they might be used by netpoll/printk
from IRQ context.

  =================================
  [ INFO: inconsistent lock state ]
  2.6.19 #11
  ---------------------------------
  inconsistent {softirq-on-W} -&gt; {in-softirq-W} usage.
  swapper/1 [HC0[0]:SC1[1]:HE1:SE0] takes:
   (&amp;npinfo-&gt;poll_lock){-+..}, at: [&lt;c0350a41&gt;] net_rx_action+0x64/0x1de
  {softirq-on-W} state was registered at:
    [&lt;c0134c86&gt;] mark_lock+0x5b/0x39c
    [&lt;c0135012&gt;] mark_held_locks+0x4b/0x68
    [&lt;c01351e9&gt;] trace_hardirqs_on+0x115/0x139
    [&lt;c02879e6&gt;] rtl8139_poll+0x3d7/0x3f4
    [&lt;c035c85d&gt;] netpoll_poll+0x82/0x32f
    [&lt;c035c775&gt;] netpoll_send_skb+0xc9/0x12f
    [&lt;c035cdcc&gt;] netpoll_send_udp+0x253/0x25b
    [&lt;c0288463&gt;] write_msg+0x40/0x65
    [&lt;c011cead&gt;] __call_console_drivers+0x45/0x51
    [&lt;c011cf16&gt;] _call_console_drivers+0x5d/0x61
    [&lt;c011d4fb&gt;] release_console_sem+0x11f/0x1d8
    [&lt;c011d7d7&gt;] register_console+0x1ac/0x1b3
    [&lt;c02883f8&gt;] init_netconsole+0x55/0x67
    [&lt;c010040c&gt;] init+0x9a/0x24e
    [&lt;c01049cf&gt;] kernel_thread_helper+0x7/0x10
    [&lt;ffffffff&gt;] 0xffffffff
  irq event stamp: 819992
  hardirqs last  enabled at (819992): [&lt;c0350a16&gt;] net_rx_action+0x39/0x1de
  hardirqs last disabled at (819991): [&lt;c0350b1e&gt;] net_rx_action+0x141/0x1de
  softirqs last  enabled at (817552): [&lt;c01214e4&gt;] __do_softirq+0xa3/0xa8
  softirqs last disabled at (819987): [&lt;c0106051&gt;] do_softirq+0x5b/0xc9

  other info that might help us debug this:
  no locks held by swapper/1.

  stack backtrace:
   [&lt;c0104d88&gt;] dump_trace+0x63/0x1e8
   [&lt;c0104f26&gt;] show_trace_log_lvl+0x19/0x2e
   [&lt;c010532d&gt;] show_trace+0x12/0x14
   [&lt;c0105343&gt;] dump_stack+0x14/0x16
   [&lt;c0134980&gt;] print_usage_bug+0x23c/0x246
   [&lt;c0134d33&gt;] mark_lock+0x108/0x39c
   [&lt;c01356a7&gt;] __lock_acquire+0x361/0x9ed
   [&lt;c0136018&gt;] lock_acquire+0x56/0x72
   [&lt;c03aff1f&gt;] _spin_lock+0x35/0x42
   [&lt;c0350a41&gt;] net_rx_action+0x64/0x1de
   [&lt;c0121493&gt;] __do_softirq+0x52/0xa8
   [&lt;c0106051&gt;] do_softirq+0x5b/0xc9
   [&lt;c0121338&gt;] irq_exit+0x3c/0x48
   [&lt;c0106163&gt;] do_IRQ+0xa4/0xbd
   [&lt;c01047c6&gt;] common_interrupt+0x2e/0x34
   [&lt;c011db92&gt;] vprintk+0x2c0/0x309
   [&lt;c011dbf6&gt;] printk+0x1b/0x1d
   [&lt;c01003f2&gt;] init+0x80/0x24e
   [&lt;c01049cf&gt;] kernel_thread_helper+0x7/0x10
   =======================

Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
Signed-off-by: Adrian Bunk &lt;bunk@stusta.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
fix deadlock in the 8139too driver: poll handlers should never forcibly
enable local interrupts, because they might be used by netpoll/printk
from IRQ context.

  =================================
  [ INFO: inconsistent lock state ]
  2.6.19 #11
  ---------------------------------
  inconsistent {softirq-on-W} -&gt; {in-softirq-W} usage.
  swapper/1 [HC0[0]:SC1[1]:HE1:SE0] takes:
   (&amp;npinfo-&gt;poll_lock){-+..}, at: [&lt;c0350a41&gt;] net_rx_action+0x64/0x1de
  {softirq-on-W} state was registered at:
    [&lt;c0134c86&gt;] mark_lock+0x5b/0x39c
    [&lt;c0135012&gt;] mark_held_locks+0x4b/0x68
    [&lt;c01351e9&gt;] trace_hardirqs_on+0x115/0x139
    [&lt;c02879e6&gt;] rtl8139_poll+0x3d7/0x3f4
    [&lt;c035c85d&gt;] netpoll_poll+0x82/0x32f
    [&lt;c035c775&gt;] netpoll_send_skb+0xc9/0x12f
    [&lt;c035cdcc&gt;] netpoll_send_udp+0x253/0x25b
    [&lt;c0288463&gt;] write_msg+0x40/0x65
    [&lt;c011cead&gt;] __call_console_drivers+0x45/0x51
    [&lt;c011cf16&gt;] _call_console_drivers+0x5d/0x61
    [&lt;c011d4fb&gt;] release_console_sem+0x11f/0x1d8
    [&lt;c011d7d7&gt;] register_console+0x1ac/0x1b3
    [&lt;c02883f8&gt;] init_netconsole+0x55/0x67
    [&lt;c010040c&gt;] init+0x9a/0x24e
    [&lt;c01049cf&gt;] kernel_thread_helper+0x7/0x10
    [&lt;ffffffff&gt;] 0xffffffff
  irq event stamp: 819992
  hardirqs last  enabled at (819992): [&lt;c0350a16&gt;] net_rx_action+0x39/0x1de
  hardirqs last disabled at (819991): [&lt;c0350b1e&gt;] net_rx_action+0x141/0x1de
  softirqs last  enabled at (817552): [&lt;c01214e4&gt;] __do_softirq+0xa3/0xa8
  softirqs last disabled at (819987): [&lt;c0106051&gt;] do_softirq+0x5b/0xc9

  other info that might help us debug this:
  no locks held by swapper/1.

  stack backtrace:
   [&lt;c0104d88&gt;] dump_trace+0x63/0x1e8
   [&lt;c0104f26&gt;] show_trace_log_lvl+0x19/0x2e
   [&lt;c010532d&gt;] show_trace+0x12/0x14
   [&lt;c0105343&gt;] dump_stack+0x14/0x16
   [&lt;c0134980&gt;] print_usage_bug+0x23c/0x246
   [&lt;c0134d33&gt;] mark_lock+0x108/0x39c
   [&lt;c01356a7&gt;] __lock_acquire+0x361/0x9ed
   [&lt;c0136018&gt;] lock_acquire+0x56/0x72
   [&lt;c03aff1f&gt;] _spin_lock+0x35/0x42
   [&lt;c0350a41&gt;] net_rx_action+0x64/0x1de
   [&lt;c0121493&gt;] __do_softirq+0x52/0xa8
   [&lt;c0106051&gt;] do_softirq+0x5b/0xc9
   [&lt;c0121338&gt;] irq_exit+0x3c/0x48
   [&lt;c0106163&gt;] do_IRQ+0xa4/0xbd
   [&lt;c01047c6&gt;] common_interrupt+0x2e/0x34
   [&lt;c011db92&gt;] vprintk+0x2c0/0x309
   [&lt;c011dbf6&gt;] printk+0x1b/0x1d
   [&lt;c01003f2&gt;] init+0x80/0x24e
   [&lt;c01049cf&gt;] kernel_thread_helper+0x7/0x10
   =======================

Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
Signed-off-by: Adrian Bunk &lt;bunk@stusta.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>ieee1394: forgotten dereference...</title>
<updated>2007-07-22T16:01:20+00:00</updated>
<author>
<name>Al Viro</name>
<email>viro@zeniv.linux.org.uk</email>
</author>
<published>2007-07-22T16:01:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=4e4c0eaae96b9a10dbde07acde81a1b488e1062e'/>
<id>4e4c0eaae96b9a10dbde07acde81a1b488e1062e</id>
<content type='text'>
Going through the string and waiting for _pointer_ to become '\0'
is not what the authors meant...

Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Acked-by: Ben Collins &lt;ben.collins@ubuntu.com&gt;
Signed-off-by: Adrian Bunk &lt;bunk@stusta.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Going through the string and waiting for _pointer_ to become '\0'
is not what the authors meant...

Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Acked-by: Ben Collins &lt;ben.collins@ubuntu.com&gt;
Signed-off-by: Adrian Bunk &lt;bunk@stusta.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>[SPARC]: Linux always started with 9600 8N1</title>
<updated>2007-07-22T15:44:18+00:00</updated>
<author>
<name>Jan Engelhardt</name>
<email>jengelh@gmx.de</email>
</author>
<published>2007-07-22T15:44:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=28cbc66ccc0fa838789ad01fabee9b25740f7468'/>
<id>28cbc66ccc0fa838789ad01fabee9b25740f7468</id>
<content type='text'>
The Linux kernel ignored the PROM's serial settings (115200,n,8,1 in
my case). This was because mode_prop remained "ttyX-mode" (expected:
"ttya-mode") due to the constness of string literals when used with
"char *". Since there is no "ttyX-mode" property in the PROM, Linux
always used the default 9600.

[ Investigation of the suncore.s assembler reveals that gcc optimizied
  away the stores, yet did not emit a warning, which is a pretty
  anti-social thing to do and is the only reason this bug lived for
  so long -DaveM ]

Signed-off-by: Jan Engelhardt &lt;jengelh@gmx.de&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Adrian Bunk &lt;bunk@stusta.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The Linux kernel ignored the PROM's serial settings (115200,n,8,1 in
my case). This was because mode_prop remained "ttyX-mode" (expected:
"ttya-mode") due to the constness of string literals when used with
"char *". Since there is no "ttyX-mode" property in the PROM, Linux
always used the default 9600.

[ Investigation of the suncore.s assembler reveals that gcc optimizied
  away the stores, yet did not emit a warning, which is a pretty
  anti-social thing to do and is the only reason this bug lived for
  so long -DaveM ]

Signed-off-by: Jan Engelhardt &lt;jengelh@gmx.de&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Adrian Bunk &lt;bunk@stusta.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>[NETPOLL]: Remove CONFIG_NETPOLL_RX</title>
<updated>2007-05-22T22:43:37+00:00</updated>
<author>
<name>Sergei Shtylyov</name>
<email>sshtylyov@ru.mvista.com</email>
</author>
<published>2007-05-22T22:43:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=00fd81fe55fbf464a952a43fd4dc3248601a5f87'/>
<id>00fd81fe55fbf464a952a43fd4dc3248601a5f87</id>
<content type='text'>
Get rid of the CONFIG_NETPOLL_RX option completely since all the
dependencies have been removed long ago...

Signed-off-by: Sergei Shtylyov &lt;sshtylyov@ru.mvista.com&gt;
Acked-by: Jeff Garzik &lt;jgarzik@pobox.com&gt;
Acked-by: Matt Mackall &lt;mpm@selenic.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Adrian Bunk &lt;bunk@stusta.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Get rid of the CONFIG_NETPOLL_RX option completely since all the
dependencies have been removed long ago...

Signed-off-by: Sergei Shtylyov &lt;sshtylyov@ru.mvista.com&gt;
Acked-by: Jeff Garzik &lt;jgarzik@pobox.com&gt;
Acked-by: Matt Mackall &lt;mpm@selenic.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Adrian Bunk &lt;bunk@stusta.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>hwmon/w83627ehf: Don't redefine REGION_OFFSET</title>
<updated>2007-05-03T23:35:12+00:00</updated>
<author>
<name>Jean Delvare</name>
<email>khali@linux-fr.org</email>
</author>
<published>2007-05-03T23:35:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=76e01e5bc0f958d7065d589ada7ca44eb44d8d3e'/>
<id>76e01e5bc0f958d7065d589ada7ca44eb44d8d3e</id>
<content type='text'>
On ia64, kernel headers define REGION_OFFSET so we can't use that.
Reported by Andrew Morton.

Signed-off-by: Jean Delvare &lt;khali@linux-fr.org&gt;
Signed-off-by: Adrian Bunk &lt;bunk@stusta.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
On ia64, kernel headers define REGION_OFFSET so we can't use that.
Reported by Andrew Morton.

Signed-off-by: Jean Delvare &lt;khali@linux-fr.org&gt;
Signed-off-by: Adrian Bunk &lt;bunk@stusta.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Char: icom, mark __init as __devinit</title>
<updated>2007-04-25T23:35:22+00:00</updated>
<author>
<name>Jiri Slaby</name>
<email>jirislaby@gmail.com</email>
</author>
<published>2007-04-25T23:35:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=0ea2b4b19d3bc0d4075a4f176a9da5797be73304'/>
<id>0ea2b4b19d3bc0d4075a4f176a9da5797be73304</id>
<content type='text'>
Two functions are called from __devinit context, but they are marked as
__init. Fix this.

Signed-off-by: Jiri Slaby &lt;jirislaby@gmail.com&gt;
Signed-off-by: Adrian Bunk &lt;bunk@stusta.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Two functions are called from __devinit context, but they are marked as
__init. Fix this.

Signed-off-by: Jiri Slaby &lt;jirislaby@gmail.com&gt;
Signed-off-by: Adrian Bunk &lt;bunk@stusta.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tty_io: fix race in master pty close/slave pty close path</title>
<updated>2007-04-20T22:18:01+00:00</updated>
<author>
<name>Aristeu Sergio Rozanski Filho</name>
<email>aris@ruivo.org</email>
</author>
<published>2007-04-20T22:18:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=fec2411aa963fafcf17823b43c2379ba3d228cd8'/>
<id>fec2411aa963fafcf17823b43c2379ba3d228cd8</id>
<content type='text'>
This patch fixes a possible race that leads to double freeing an idr index.
 When the master begin to close, release_dev() is called and then
pty_close() is called:

        if (tty-&gt;driver-&gt;close)
                tty-&gt;driver-&gt;close(tty, filp);

This is done without helding any locks other than BKL.  Inside pty_close(),
being a master close, the devpts entry will be removed:

#ifdef CONFIG_UNIX98_PTYS
                if (tty-&gt;driver == ptm_driver)
                        devpts_pty_kill(tty-&gt;index);
#endif

But devpts_pty_kill() will call get_node() that may sleep while waiting for
&amp;devpts_root-&gt;d_inode-&gt;i_sem.  When this happens and the slave is being
opened, tty_open() just found the driver and index:

        driver = get_tty_driver(device, &amp;index);
        if (!driver) {
                mutex_unlock(&amp;tty_mutex);
                return -ENODEV;
        }

This part of the code is already protected under tty_mute.  The problem is
that the slave close already got an index.  Then init_dev() is called and
blocks waiting for the same &amp;devpts_root-&gt;d_inode-&gt;i_sem.

When the master close resumes, it removes the devpts entry, and the
relation between idr index and the tty is gone.  The master then sleeps
waiting for the tty_mutex on release_dev().

Slave open resumes and found no tty for that index.  As result, a NULL tty
is returned and init_dev() doesn't flow to fast_track:

        /* check whether we're reopening an existing tty */
        if (driver-&gt;flags &amp; TTY_DRIVER_DEVPTS_MEM) {
                tty = devpts_get_tty(idx);
                if (tty &amp;&amp; driver-&gt;subtype == PTY_TYPE_MASTER)
                        tty = tty-&gt;link;
        } else {
                tty = driver-&gt;ttys[idx];
        }
        if (tty) goto fast_track;

The result of this, is that a new tty will be created and init_dev() returns
sucessfull. After returning, tty_mutex is dropped and master close may resume.

Master close finds it's the only use and both sides are closing, then releases
the tty and the index. At this point, the idr index is free, but slave still
has it.

Slave open then calls pty_open() and finds that tty-&gt;link-&gt;count is 0,
because there's no master and returns error.  Then tty_open() calls
release_dev() which executes without any warning, as it was a case of last
slave close when the master is already closed (master-&gt;count == 0,
slave-&gt;count == 1).  The tty is then released with the already released idr
index.

This normally would only issue a warning on idr_remove() but in case of a
customer's critical application, it's never too simple:

thread1: opens master, gets index X
thread1: begin closing master
thread2: begin opening slave with index X
thread1: finishes closing master, index X released
thread3: opens master, gets index X, just released
thread2: fails opening slave, releases index X         &lt;----
thread4: opens master, gets index X, init_dev() then find an already in use
         and healthy tty and fails

If no more indexes are released, ptmx_open() will keep failing, as the
first free index available is X, and it will make init_dev() fail because
you're trying to "reopen a master" which isn't valid.

The patch notices when this race happens and make init_dev() fail
imediately.  The init_dev() function is called with tty_mutex held, so it's
safe to continue with tty till the end of function because release_dev()
won't make any further changes without grabbing the tty_mutex.

Without the patch, on some machines it's possible get easily idr warnings
like this one:

idr_remove called for id=15 which is not allocated.
 [&lt;c02555b9&gt;] idr_remove+0x139/0x170
 [&lt;c02a1b62&gt;] release_mem+0x182/0x230
 [&lt;c02a28e7&gt;] release_dev+0x4b7/0x700
 [&lt;c02a0ea7&gt;] tty_ldisc_enable+0x27/0x30
 [&lt;c02a1e64&gt;] init_dev+0x254/0x580
 [&lt;c02a0d64&gt;] check_tty_count+0x14/0xb0
 [&lt;c02a4f05&gt;] tty_open+0x1c5/0x340
 [&lt;c02a4d40&gt;] tty_open+0x0/0x340
 [&lt;c017388f&gt;] chrdev_open+0xaf/0x180
 [&lt;c017c2ac&gt;] open_namei+0x8c/0x760
 [&lt;c01737e0&gt;] chrdev_open+0x0/0x180
 [&lt;c0167bc9&gt;] __dentry_open+0xc9/0x210
 [&lt;c0167e2c&gt;] do_filp_open+0x5c/0x70
 [&lt;c0167a91&gt;] get_unused_fd+0x61/0xd0
 [&lt;c0167e93&gt;] do_sys_open+0x53/0x100
 [&lt;c0167f97&gt;] sys_open+0x27/0x30
 [&lt;c010303b&gt;] syscall_call+0x7/0xb

using this test application available on:
 http://www.ruivo.org/~aris/pty_sodomizer.c

Signed-off-by: Aristeu Sergio Rozanski Filho &lt;aris@ruivo.org&gt;
Signed-off-by: Adrian Bunk &lt;bunk@stusta.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch fixes a possible race that leads to double freeing an idr index.
 When the master begin to close, release_dev() is called and then
pty_close() is called:

        if (tty-&gt;driver-&gt;close)
                tty-&gt;driver-&gt;close(tty, filp);

This is done without helding any locks other than BKL.  Inside pty_close(),
being a master close, the devpts entry will be removed:

#ifdef CONFIG_UNIX98_PTYS
                if (tty-&gt;driver == ptm_driver)
                        devpts_pty_kill(tty-&gt;index);
#endif

But devpts_pty_kill() will call get_node() that may sleep while waiting for
&amp;devpts_root-&gt;d_inode-&gt;i_sem.  When this happens and the slave is being
opened, tty_open() just found the driver and index:

        driver = get_tty_driver(device, &amp;index);
        if (!driver) {
                mutex_unlock(&amp;tty_mutex);
                return -ENODEV;
        }

This part of the code is already protected under tty_mute.  The problem is
that the slave close already got an index.  Then init_dev() is called and
blocks waiting for the same &amp;devpts_root-&gt;d_inode-&gt;i_sem.

When the master close resumes, it removes the devpts entry, and the
relation between idr index and the tty is gone.  The master then sleeps
waiting for the tty_mutex on release_dev().

Slave open resumes and found no tty for that index.  As result, a NULL tty
is returned and init_dev() doesn't flow to fast_track:

        /* check whether we're reopening an existing tty */
        if (driver-&gt;flags &amp; TTY_DRIVER_DEVPTS_MEM) {
                tty = devpts_get_tty(idx);
                if (tty &amp;&amp; driver-&gt;subtype == PTY_TYPE_MASTER)
                        tty = tty-&gt;link;
        } else {
                tty = driver-&gt;ttys[idx];
        }
        if (tty) goto fast_track;

The result of this, is that a new tty will be created and init_dev() returns
sucessfull. After returning, tty_mutex is dropped and master close may resume.

Master close finds it's the only use and both sides are closing, then releases
the tty and the index. At this point, the idr index is free, but slave still
has it.

Slave open then calls pty_open() and finds that tty-&gt;link-&gt;count is 0,
because there's no master and returns error.  Then tty_open() calls
release_dev() which executes without any warning, as it was a case of last
slave close when the master is already closed (master-&gt;count == 0,
slave-&gt;count == 1).  The tty is then released with the already released idr
index.

This normally would only issue a warning on idr_remove() but in case of a
customer's critical application, it's never too simple:

thread1: opens master, gets index X
thread1: begin closing master
thread2: begin opening slave with index X
thread1: finishes closing master, index X released
thread3: opens master, gets index X, just released
thread2: fails opening slave, releases index X         &lt;----
thread4: opens master, gets index X, init_dev() then find an already in use
         and healthy tty and fails

If no more indexes are released, ptmx_open() will keep failing, as the
first free index available is X, and it will make init_dev() fail because
you're trying to "reopen a master" which isn't valid.

The patch notices when this race happens and make init_dev() fail
imediately.  The init_dev() function is called with tty_mutex held, so it's
safe to continue with tty till the end of function because release_dev()
won't make any further changes without grabbing the tty_mutex.

Without the patch, on some machines it's possible get easily idr warnings
like this one:

idr_remove called for id=15 which is not allocated.
 [&lt;c02555b9&gt;] idr_remove+0x139/0x170
 [&lt;c02a1b62&gt;] release_mem+0x182/0x230
 [&lt;c02a28e7&gt;] release_dev+0x4b7/0x700
 [&lt;c02a0ea7&gt;] tty_ldisc_enable+0x27/0x30
 [&lt;c02a1e64&gt;] init_dev+0x254/0x580
 [&lt;c02a0d64&gt;] check_tty_count+0x14/0xb0
 [&lt;c02a4f05&gt;] tty_open+0x1c5/0x340
 [&lt;c02a4d40&gt;] tty_open+0x0/0x340
 [&lt;c017388f&gt;] chrdev_open+0xaf/0x180
 [&lt;c017c2ac&gt;] open_namei+0x8c/0x760
 [&lt;c01737e0&gt;] chrdev_open+0x0/0x180
 [&lt;c0167bc9&gt;] __dentry_open+0xc9/0x210
 [&lt;c0167e2c&gt;] do_filp_open+0x5c/0x70
 [&lt;c0167a91&gt;] get_unused_fd+0x61/0xd0
 [&lt;c0167e93&gt;] do_sys_open+0x53/0x100
 [&lt;c0167f97&gt;] sys_open+0x27/0x30
 [&lt;c010303b&gt;] syscall_call+0x7/0xb

using this test application available on:
 http://www.ruivo.org/~aris/pty_sodomizer.c

Signed-off-by: Aristeu Sergio Rozanski Filho &lt;aris@ruivo.org&gt;
Signed-off-by: Adrian Bunk &lt;bunk@stusta.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>hwmon/w83627ehf: Fix the fan5 clock divider write</title>
<updated>2007-04-19T23:43:12+00:00</updated>
<author>
<name>Jean Delvare</name>
<email>khali@linux-fr.org</email>
</author>
<published>2007-04-19T23:43:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=17acc02c4df45426d62e5e31231a2312c361f107'/>
<id>17acc02c4df45426d62e5e31231a2312c361f107</id>
<content type='text'>
Users have been complaining about the w83627ehf driver flooding their logs
with debug messages like:

w83627ehf 9191-0a10: Increasing fan 4 clock divider from 64 to 128

or:

w83627ehf 9191-0290: Increasing fan 4 clock divider from 4 to 8

The reason is that we failed to actually write the LSB of the encoded clock
divider value for that fan, causing the next read to report the same old value
again and again.

Additionally, the fan number was improperly reported, making the bug harder to
find.

Signed-off-by: Jean Delvare &lt;khali@linux-fr.org&gt;
Signed-off-by: Adrian Bunk &lt;bunk@stusta.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Users have been complaining about the w83627ehf driver flooding their logs
with debug messages like:

w83627ehf 9191-0a10: Increasing fan 4 clock divider from 64 to 128

or:

w83627ehf 9191-0290: Increasing fan 4 clock divider from 4 to 8

The reason is that we failed to actually write the LSB of the encoded clock
divider value for that fan, causing the next read to report the same old value
again and again.

Additionally, the fan number was improperly reported, making the bug harder to
find.

Signed-off-by: Jean Delvare &lt;khali@linux-fr.org&gt;
Signed-off-by: Adrian Bunk &lt;bunk@stusta.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>[SCSI] QLOGICPTI: Do not unmap DMA unless we actually mapped something.</title>
<updated>2007-04-19T23:31:17+00:00</updated>
<author>
<name>David S. Miller</name>
<email>davem@davemloft.net</email>
</author>
<published>2007-04-19T23:31:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=ad65d701caf0937add48e1c54263850a6a382d27'/>
<id>ad65d701caf0937add48e1c54263850a6a382d27</id>
<content type='text'>
We only map DMA when cmd-&gt;request_bufflen is non-zero for non-sg
buffers, we thus should make the same check when unmapping.

Based upon a report from Pasi Pirhonen.

Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Adrian Bunk &lt;bunk@stusta.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We only map DMA when cmd-&gt;request_bufflen is non-zero for non-sg
buffers, we thus should make the same check when unmapping.

Based upon a report from Pasi Pirhonen.

Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Adrian Bunk &lt;bunk@stusta.de&gt;
</pre>
</div>
</content>
</entry>
</feed>
