<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/drivers/pps/pps.c, branch v3.4.89</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v3.4.89</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v3.4.89'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2014-04-14T13:44:17Z</updated>
<entry>
<title>pps: Fix a use-after free bug when unregistering a source.</title>
<updated>2014-04-14T13:44:17Z</updated>
<author>
<name>George Spelvin</name>
<email>linux@horizon.com</email>
</author>
<published>2013-02-12T07:27:20Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=cd59fb14918a6b20c1ac8be121fa6397b97b00cb'/>
<id>urn:sha1:cd59fb14918a6b20c1ac8be121fa6397b97b00cb</id>
<content type='text'>
commit d953e0e837e65ecc1ddaa4f9560f7925878a0de6 upstream.

Remove the cdev from the system (with cdev_del) *before* deallocating it
(in pps_device_destruct, called via kobject_put from device_destroy).

Also prevent deallocating a device with open file handles.

A better long-term fix is probably to remove the cdev from the pps_device
entirely, and instead have all devices reference one global cdev.  Then
the deallocation ordering becomes simpler.

But that's more complex and invasive change, so we leave that
for later.

Signed-off-by: George Spelvin &lt;linux@horizon.com&gt;
Acked-by: Rodolfo Giometti &lt;giometti@enneenne.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
Cc: Qiang Huang &lt;h.huangqiang@huawei.com&gt;
Cc: Li Zefan &lt;lizefan@huawei.com&gt;
Cc: Jianguo Wu &lt;wujianguo@huawei.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>pps: Add pps_lookup_dev() function</title>
<updated>2014-04-14T13:44:17Z</updated>
<author>
<name>George Spelvin</name>
<email>linux@horizon.com</email>
</author>
<published>2013-02-10T09:08:32Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=71a521898740fc57b062dddd9cff51c9e835cd43'/>
<id>urn:sha1:71a521898740fc57b062dddd9cff51c9e835cd43</id>
<content type='text'>
commit 513b032c98b4b9414aa4e9b4a315cb1bf0380101 upstream.

The PPS serial line discipline wants to attach a PPS device to a tty
without changing the tty code to add a struct pps_device * pointer.

Since the number of PPS devices in a typical system is generally very low
(n=1 is by far the most common), it's practical to search the entire list
of allocated pps devices.  (We capture the timestamp before the lookup,
so the timing isn't affected.)

It is a bit ugly that this function, which is part of the in-kernel
PPS API, has to be in pps.c as opposed to kapi,c, but that's not
something that affects users.

Signed-off-by: George Spelvin &lt;linux@horizon.com&gt;
Acked-by: Rodolfo Giometti &lt;giometti@enneenne.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
Cc: Qiang Huang &lt;h.huangqiang@huawei.com&gt;
Cc: Li Zefan &lt;lizefan@huawei.com&gt;
Cc: Jianguo Wu &lt;wujianguo@huawei.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>pps: class_create() returns an ERR_PTR, not NULL</title>
<updated>2012-03-05T23:49:43Z</updated>
<author>
<name>Dan Carpenter</name>
<email>dan.carpenter@oracle.com</email>
</author>
<published>2012-03-05T22:59:15Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=7ad12566dc02ca76e0056af58606b5ce0181460f'/>
<id>urn:sha1:7ad12566dc02ca76e0056af58606b5ce0181460f</id>
<content type='text'>
class_create() never returns NULLs only ERR_PTRs.

Signed-off-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Cc: Rodolfo Giometti &lt;giometti@enneenne.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>pps: add kernel consumer support</title>
<updated>2011-01-13T16:03:21Z</updated>
<author>
<name>Alexander Gordeev</name>
<email>lasaine@lvk.cs.msu.su</email>
</author>
<published>2011-01-13T01:00:58Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=717c033669ed3ceaee8df57d4562fafcc1a6267a'/>
<id>urn:sha1:717c033669ed3ceaee8df57d4562fafcc1a6267a</id>
<content type='text'>
Add an optional feature of PPSAPI, kernel consumer support, which uses the
added hardpps() function.

Signed-off-by: Alexander Gordeev &lt;lasaine@lvk.cs.msu.su&gt;
Acked-by: Rodolfo Giometti &lt;giometti@linux.it&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>pps: make idr lock a mutex and protect idr_pre_get</title>
<updated>2011-01-13T16:03:20Z</updated>
<author>
<name>Alexander Gordeev</name>
<email>lasaine@lvk.cs.msu.su</email>
</author>
<published>2011-01-13T01:00:53Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=2a5cd6e2fb1984cc83f08b3645bf394830ac7825'/>
<id>urn:sha1:2a5cd6e2fb1984cc83f08b3645bf394830ac7825</id>
<content type='text'>
Now pps_idr_lock is never used in interrupt context so we can replace
spin_lock_irq/spin_unlock_irq with plain spin_lock/spin_unlock. But
there is also a potential race condition when someone can steal an id
which was allocated by idr_pre_get before it is used. So convert spin
lock to mutex and protect the whole id generation process.

Signed-off-by: Alexander Gordeev &lt;lasaine@lvk.cs.msu.su&gt;
Cc: Rodolfo Giometti &lt;giometti@linux.it&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>pps: move idr stuff to pps.c</title>
<updated>2011-01-13T16:03:20Z</updated>
<author>
<name>Alexander Gordeev</name>
<email>lasaine@lvk.cs.msu.su</email>
</author>
<published>2011-01-13T01:00:53Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=083e58666ff5b3c5750d9a5c0560018b03cfb4b2'/>
<id>urn:sha1:083e58666ff5b3c5750d9a5c0560018b03cfb4b2</id>
<content type='text'>
Since now idr is only used to manage char device id's and not used in
kernel API anymore it should be moved to pps.c.  This also makes it
possible to release id only at actual device freeing so nobody can
register a pps device with the same id while our device is not freed yet.

Signed-off-by: Alexander Gordeev &lt;lasaine@lvk.cs.msu.su&gt;
Acked-by: Rodolfo Giometti &lt;giometti@linux.it&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>pps: convert printk/pr_* to dev_*</title>
<updated>2011-01-13T16:03:19Z</updated>
<author>
<name>Alexander Gordeev</name>
<email>lasaine@lvk.cs.msu.su</email>
</author>
<published>2011-01-13T01:00:52Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=7f7cce74105adf714bdc9357da3b6f06e019958c'/>
<id>urn:sha1:7f7cce74105adf714bdc9357da3b6f06e019958c</id>
<content type='text'>
Since we now have direct pointers to struct pps_device everywhere it's
easy to use dev_* functions to print messages instead of plain printks.
Where dev_* cannot be used printks are converted to pr_*.

Signed-off-by: Alexander Gordeev &lt;lasaine@lvk.cs.msu.su&gt;
Acked-by: Rodolfo Giometti &lt;giometti@linux.it&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>pps: access pps device by direct pointer</title>
<updated>2011-01-13T16:03:19Z</updated>
<author>
<name>Alexander Gordeev</name>
<email>lasaine@lvk.cs.msu.su</email>
</author>
<published>2011-01-13T01:00:51Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=5e196d34a776420278e4117b4742cd9d3f2350ed'/>
<id>urn:sha1:5e196d34a776420278e4117b4742cd9d3f2350ed</id>
<content type='text'>
Using device index as a pointer needs some unnecessary work to be done
every time the pointer is needed (in irq handler for example).  Using a
direct pointer is much more easy (and safe as well).

Signed-off-by: Alexander Gordeev &lt;lasaine@lvk.cs.msu.su&gt;
Acked-by: Rodolfo Giometti &lt;giometti@linux.it&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>pps: fix race in PPS_FETCH handler</title>
<updated>2011-01-13T16:03:19Z</updated>
<author>
<name>Alexander Gordeev</name>
<email>lasaine@lvk.cs.msu.su</email>
</author>
<published>2011-01-13T01:00:50Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=3003d55b59aa98aeaff2773df69732b27c0cbf6a'/>
<id>urn:sha1:3003d55b59aa98aeaff2773df69732b27c0cbf6a</id>
<content type='text'>
There was a race in PPS_FETCH ioctl handler when several processes want to
obtain PPS data simultaneously using sleeping PPS_FETCH.  They all sleep
most of the time in the system call.

With the old approach when the first process waiting on the pps queue is
waken up it makes new system call right away and zeroes pps-&gt;go.  So other
processes continue to sleep.  This is a clear race condition because of
the global 'go' variable.

With the new approach pps-&gt;last_ev holds some value increasing at each PPS
event.  PPS_FETCH ioctl handler saves current value to the local variable
at the very beginning so it can safely check that there is a new event by
just comparing both variables.

Signed-off-by: Alexander Gordeev &lt;lasaine@lvk.cs.msu.su&gt;
Acked-by: Rodolfo Giometti &lt;giometti@linux.it&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>pps: declare variables where they are used in switch</title>
<updated>2011-01-13T16:03:19Z</updated>
<author>
<name>Alexander Gordeev</name>
<email>lasaine@lvk.cs.msu.su</email>
</author>
<published>2011-01-13T01:00:49Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=86d921f9ec06bc3fd357a77877d37a604d5674c3'/>
<id>urn:sha1:86d921f9ec06bc3fd357a77877d37a604d5674c3</id>
<content type='text'>
Move variable declarations where they are used in pps_cdev_ioctl.

Signed-off-by: Alexander Gordeev &lt;lasaine@lvk.cs.msu.su&gt;
Acked-by: Rodolfo Giometti &lt;giometti@linux.it&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
</feed>
