Re: [patch 1/3] tty: resolve tty contention between kernel and user space

2017-07-10 Thread Okash Khawaja
On Mon, Jul 10, 2017 at 06:21:37PM +0300, Andy Shevchenko wrote: > On Mon, Jul 10, 2017 at 11:31 AM, Okash Khawaja > wrote: > > On Sun, Jul 09, 2017 at 06:04:17PM +0300, Andy Shevchenko wrote: > >> On Sun, Jul 9, 2017 at 2:41 PM, Okash Khawaja > >> wrote: > >> > >> > +struct tty_struct *tty_kop

Re: [patch 1/3] tty: resolve tty contention between kernel and user space

2017-07-10 Thread Andy Shevchenko
On Mon, Jul 10, 2017 at 11:31 AM, Okash Khawaja wrote: > On Sun, Jul 09, 2017 at 06:04:17PM +0300, Andy Shevchenko wrote: >> On Sun, Jul 9, 2017 at 2:41 PM, Okash Khawaja >> wrote: >> >> > +struct tty_struct *tty_kopen(dev_t device) >> > +{ >> > + struct tty_struct *tty; >> > + struc

Re: [patch 1/3] tty: resolve tty contention between kernel and user space

2017-07-10 Thread Okash Khawaja
On Sun, Jul 09, 2017 at 06:04:17PM +0300, Andy Shevchenko wrote: > On Sun, Jul 9, 2017 at 2:41 PM, Okash Khawaja wrote: > > > +struct tty_struct *tty_kopen(dev_t device) > > +{ > > + struct tty_struct *tty; > > + struct tty_driver *driver = NULL; > > + int index = -1; > > + > >

Re: [patch 1/3] tty: resolve tty contention between kernel and user space

2017-07-09 Thread Okash Khawaja
Hi, On Sun, Jul 09, 2017 at 06:04:17PM +0300, Andy Shevchenko wrote: > Above > 1. take mutex > 2. take reference > > Here: > 1. give mutex back > 2. give reference back > > I think we usually see symmetrical calls, i.e. > > 1. give reference back > 2. give mutex back > > So, what did I miss

Re: [patch 1/3] tty: resolve tty contention between kernel and user space

2017-07-09 Thread Andy Shevchenko
On Sun, Jul 9, 2017 at 2:41 PM, Okash Khawaja wrote: > +struct tty_struct *tty_kopen(dev_t device) > +{ > + struct tty_struct *tty; > + struct tty_driver *driver = NULL; > + int index = -1; > + > + mutex_lock(&tty_mutex); > + driver = tty_lookup_driver(device, NULL,

Re: [patch 1/3] tty: resolve tty contention between kernel and user space

2017-07-09 Thread Greg Kroah-Hartman
On Sun, Jul 09, 2017 at 12:41:54PM +0100, Okash Khawaja wrote: > The commit 12e84c71b7d4ee (tty: export tty_open_by_driver) exports > tty_open_by_device to allow tty to be opened from inside kernel which > works fine except that it doesn't handle contention with user space or > another kernel-space