Messages in this thread | | | Date | Thu, 12 Jul 2018 08:13:14 -0600 | From | Tycho Andersen <> | Subject | Re: [PATCH v4] uart: fix race between uart_put_char() and uart_shutdown() |
| |
Hi Andy,
On Thu, Jul 12, 2018 at 12:03:08PM +0300, Andy Shevchenko wrote: > On Wed, Jul 11, 2018 at 7:07 PM, Tycho Andersen <tycho@tycho.ws> wrote: > > > Anyway, since the lock is not acquired, if uart_shutdown() is called, the > > last chunk of that function may release state->xmit.buf before its assigned > > to null, and cause the race above. > > > > To fix it, let's lock uport->lock when allocating/deallocating > > state->xmit.buf in addition to the per-port mutex. > > > * use the result of uart_port_lock() in uart_shutdown() to avoid > > uninitialized warning > > * don't use the uart_port_lock/unlock macros in uart_port_startup, > > instead test against uport directly; the compiler can't seem to "see" > > through the macros/ref/unref calls to not warn about uninitialized > > flags. We don't need to do a ref here since we hold the per-port > > mutex anyway. > > > + if (uport) > > + spin_lock_irqsave(&uport->lock, flags); > > > + if (uport) > > + spin_unlock_irqrestore(&uport->lock, flags); > > At some point it It was uart_port_lock()/uart_port_unlock(), and you > changed to simple spin lock. The macro also take reference to the > port. Do we aware about that here?
I don't think so, the commit message you quoted above says,
> We don't need to do a ref here since we hold the per-port mutex > anyway.
Cheers,
Tycho
| |