Skip to content

Commit

Permalink
NFC: nfcmrvl_uart: add missing tty-device sanity check
Browse files Browse the repository at this point in the history
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: e097dc6 ("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>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
  • Loading branch information
Johan Hovold authored and Samuel Ortiz committed Jun 18, 2017
1 parent 20777bc commit 15e0c59
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/nfc/nfcmrvl/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,16 @@ 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
* by low level serial driver. We can try to retrieve serial device
* 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) {
Expand All @@ -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);

Expand Down

0 comments on commit 15e0c59

Please sign in to comment.