serial: ifx6x60: Free memory when probe fails
authorSouptick Joarder <jrdr.linux@gmail.com>
Fri, 28 Oct 2016 12:00:16 +0000 (17:30 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Nov 2016 13:50:46 +0000 (14:50 +0100)
When spi_setup() fails it doesn't free ifx_dev and we have a memory
leak. Fix this by freeing ifx_dev before the return.

Signed-off-by: Souptick joarder <jrdr.linux@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/ifx6x60.c

index d386346248deba5026224d590b6be60fe5a2af91..157883653256da9ebeae89d7dabead3285656c82 100644 (file)
@@ -1042,6 +1042,7 @@ static int ifx_spi_spi_probe(struct spi_device *spi)
        ret = spi_setup(spi);
        if (ret) {
                dev_err(&spi->dev, "SPI setup wasn't successful %d", ret);
+               kfree(ifx_dev);
                return -ENODEV;
        }