serdev: ttyport: check whether tty_init_dev() fails
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 8 Feb 2017 07:23:24 +0000 (10:23 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Feb 2017 12:54:49 +0000 (13:54 +0100)
My static checker complains that we don't have any error handling here.
It's simple enough to add it.

Fixes: bed35c6dfa6a ("serdev: add a tty port controller driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serdev/serdev-ttyport.c

index 683320b81a2b374d1c07537f33e57d39cba1b939..d05393594f1505b4e82686e417114adfcf1d1e80 100644 (file)
@@ -97,6 +97,8 @@ static int ttyport_open(struct serdev_controller *ctrl)
        struct ktermios ktermios;
 
        tty = tty_init_dev(serport->tty_drv, serport->tty_idx);
+       if (IS_ERR(tty))
+               return PTR_ERR(tty);
        serport->tty = tty;
 
        serport->port->client_ops = &client_ops;