gnss: fix potential error pointer dereference
authorDan Carpenter <[email protected]>
Mon, 16 Jul 2018 10:42:03 +0000 (12:42 +0200)
committerGreg Kroah-Hartman <[email protected]>
Mon, 16 Jul 2018 10:48:07 +0000 (12:48 +0200)
The gnss_allocate_device() function returns a mix of NULL and error
pointers on error.  It should only return one or the other.  Since the
callers both check for NULL, I've modified it to return NULL on error.

Fixes: 2b6a44035143 ("gnss: add GNSS receiver subsystem")
Signed-off-by: Dan Carpenter <[email protected]>
Signed-off-by: Johan Hovold <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
drivers/gnss/core.c

index f30ef8338b3a0fa2330c7355f8e5a34a53add23a..4291a0dd22aae45f6550c6b30344084866ff6092 100644 (file)
@@ -235,7 +235,7 @@ struct gnss_device *gnss_allocate_device(struct device *parent)
        id = ida_simple_get(&gnss_minors, 0, GNSS_MINORS, GFP_KERNEL);
        if (id < 0) {
                kfree(gdev);
-               return ERR_PTR(id);
+               return NULL;
        }
 
        gdev->id = id;
@@ -270,7 +270,7 @@ struct gnss_device *gnss_allocate_device(struct device *parent)
 err_put_device:
        put_device(dev);
 
-       return ERR_PTR(-ENOMEM);
+       return NULL;
 }
 EXPORT_SYMBOL_GPL(gnss_allocate_device);