Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1616373
| From | Ben Hutchings <ben.hutchings@codethink.co.uk> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 4.4 74/76] serial: 8250_pci: Detach low-level driver during PCI error recovery |
| Date | 2017-04-04 22:30 +0200 |
| Message-ID | <tsDfs-1js-5@gated-at.bofh.it> (permalink) |
| References | <tpYzL-7we-3@gated-at.bofh.it> <tpZFx-8kZ-41@gated-at.bofh.it> |
| Organization | Codethink Ltd. |
On Tue, 2017-03-28 at 14:31 +0200, Greg Kroah-Hartman wrote:
[...]
> static void serial8250_io_resume(struct pci_dev *dev)
> {
> struct serial_private *priv = pci_get_drvdata(dev);
> + const struct pciserial_board *board;
>
> - if (priv)
> - pciserial_resume_ports(priv);
> + if (!priv)
> + return;
> +
> + board = priv->board;
> + kfree(priv);
> + priv = pciserial_init_ports(dev, board);
> +
> + if (!IS_ERR(priv)) {
> + pci_set_drvdata(dev, priv);
> + }
> }
On error, this leaves drvdata as a dangling pointer. Removing the
device or driver will then cause a use-after-free. (And setting drvdata
to NULL isn't enough to fix this as there is no null pointer check in
pciserial_remove_ports().)
Ben.
--
Ben Hutchings
Software Developer, Codethink Ltd.
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH 4.4 74/76] serial: 8250_pci: Detach low-level driver during PCI error recovery Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-03-28 15:50 +0200 Re: [PATCH 4.4 74/76] serial: 8250_pci: Detach low-level driver during PCI error recovery Ben Hutchings <ben.hutchings@codethink.co.uk> - 2017-04-04 22:30 +0200
csiph-web