staging: pi433: add missing call to cdev_del()
authorMichael Straube <straube.linux@gmail.com>
Mon, 26 Nov 2018 18:18:20 +0000 (19:18 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 5 Dec 2018 08:39:45 +0000 (09:39 +0100)
If cdev_add() fails, cdev_del() should be called.
Add the missing cdev_del() call as pointed out by
Dan Carpenter.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/pi433/pi433_if.c

index d72de21..b231463 100644 (file)
@@ -1254,7 +1254,7 @@ static int pi433_probe(struct spi_device *spi)
        retval = cdev_add(device->cdev, device->devt, 1);
        if (retval) {
                dev_dbg(device->dev, "register of cdev failed");
-               goto cdev_failed;
+               goto del_cdev;
        }
 
        /* spi setup */
@@ -1262,6 +1262,8 @@ static int pi433_probe(struct spi_device *spi)
 
        return 0;
 
+del_cdev:
+       cdev_del(device->cdev);
 cdev_failed:
        kthread_stop(device->tx_task_struct);
 send_thread_failed: