Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1722790
| From | Andy Shevchenko <andriy.shevchenko@linux.intel.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH][serial-next] serial: 8250: don't dereference em485 until it has been null checked |
| Date | 2017-08-29 22:00 +0200 |
| Message-ID | <ujUQ2-6TY-7@gated-at.bofh.it> (permalink) |
| References | <ujS1Q-54r-15@gated-at.bofh.it> |
| Organization | Intel Finland Oy |
On Tue, 2017-08-29 at 17:58 +0100, Colin King wrote:
> Currently, the pointer em485 is dereferenced to get p and then later
> em485 is checked to see if it is null before calling __start_tx. In
> the case where em485 is null, we get a null pointer dereference. Fix
> this by moving the deference and the associated spinlock/unlocks on
> p to the code block where em485 is known to be not null.
> static enum hrtimer_restart serial8250_em485_handle_start_tx(struct
> hrtimer *t)
> {
> struct uart_8250_em485 *em485;
> - struct uart_8250_port *p;
> unsigned long flags;
> em485 = container_of(t, struct uart_8250_em485,
> start_tx_timer);
> - p = em485->port;
>
> - spin_lock_irqsave(&p->port.lock, flags);
> if (em485 &&
> em485->active_timer == &em485->start_tx_timer) {
> + struct uart_8250_port *p = em485->port;
> +
> + spin_lock_irqsave(&p->port.lock, flags);
Can you describe, please, what on your opinion is protected by this
lock?
> __start_tx(&p->port);
> em485->active_timer = NULL;
> + spin_unlock_irqrestore(&p->port.lock, flags);
> }
> - spin_unlock_irqrestore(&p->port.lock, flags);
> return HRTIMER_NORESTART;
> }
>
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH][serial-next] serial: 8250: don't dereference em485 until it has been null checked Colin King <colin.king@canonical.com> - 2017-08-29 19:00 +0200
Re: [PATCH][serial-next] serial: 8250: don't dereference em485 until it has been null checked Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2017-08-29 22:00 +0200
Re: [PATCH][serial-next] serial: 8250: don't dereference em485 until it has been null checked Dan Carpenter <dan.carpenter@oracle.com> - 2017-08-29 22:10 +0200
Re: [PATCH][serial-next] serial: 8250: don't dereference em485 until it has been null checked Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2017-08-29 22:30 +0200
csiph-web