Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1612901
| From | Johan Hovold <johan@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v2 2/8] NFC: nfcmrvl_uart: add missing tty-device sanity check |
| Date | 2017-03-30 12:30 +0200 |
| Message-ID | <tqFv4-4UX-19@gated-at.bofh.it> (permalink) |
| References | <tqFlo-4ME-21@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Make sure to check the tty-device pointer before trying to access the
parent device to avoid dereferencing a NULL-pointer when the tty is one
end of a Unix98 pty.
Fixes: e097dc624f78 ("NFC: nfcmrvl: add UART driver")
Cc: stable <stable@vger.kernel.org> # 4.2
Cc: Vincent Cuissard <cuissard@marvell.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/nfc/nfcmrvl/uart.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/nfc/nfcmrvl/uart.c b/drivers/nfc/nfcmrvl/uart.c
index 83a99e38e7bd..6c0c301611c4 100644
--- a/drivers/nfc/nfcmrvl/uart.c
+++ b/drivers/nfc/nfcmrvl/uart.c
@@ -109,6 +109,7 @@ static int nfcmrvl_nci_uart_open(struct nci_uart *nu)
struct nfcmrvl_private *priv;
struct nfcmrvl_platform_data *pdata = NULL;
struct nfcmrvl_platform_data config;
+ struct device *dev = nu->tty->dev;
/*
* Platform data cannot be used here since usually it is already used
@@ -116,9 +117,8 @@ static int nfcmrvl_nci_uart_open(struct nci_uart *nu)
* and check if DT entries were added.
*/
- if (nu->tty->dev->parent && nu->tty->dev->parent->of_node)
- if (nfcmrvl_uart_parse_dt(nu->tty->dev->parent->of_node,
- &config) == 0)
+ if (dev && dev->parent && dev->parent->of_node)
+ if (nfcmrvl_uart_parse_dt(dev->parent->of_node, &config) == 0)
pdata = &config;
if (!pdata) {
@@ -131,7 +131,7 @@ static int nfcmrvl_nci_uart_open(struct nci_uart *nu)
}
priv = nfcmrvl_nci_register_dev(NFCMRVL_PHY_UART, nu, &uart_ops,
- nu->tty->dev, pdata);
+ dev, pdata);
if (IS_ERR(priv))
return PTR_ERR(priv);
--
2.12.2
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2 0/8] NFC: fix device allocation and nfcmrvl crashes Johan Hovold <johan@kernel.org> - 2017-03-30 12:30 +0200 [PATCH v2 1/8] NFC: fix broken device allocation Johan Hovold <johan@kernel.org> - 2017-03-30 12:30 +0200 [PATCH v2 2/8] NFC: nfcmrvl_uart: add missing tty-device sanity check Johan Hovold <johan@kernel.org> - 2017-03-30 12:30 +0200 [PATCH v2 4/8] NFC: nfcmrvl: use nfc-device for firmware download Johan Hovold <johan@kernel.org> - 2017-03-30 12:30 +0200 [PATCH v2 7/8] NFC: nfcmrvl_usb: use interface as phy device Johan Hovold <johan@kernel.org> - 2017-03-30 12:30 +0200 [PATCH v2 5/8] NFC: nfcmrvl: fix firmware-management initialisation Johan Hovold <johan@kernel.org> - 2017-03-30 12:30 +0200
csiph-web