提交 d9995a0f 编写于 作者: D Dan Carpenter 提交者: Greg Kroah-Hartman

gnss: fix potential error pointer dereference

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: 2b6a4403 ("gnss: add GNSS receiver subsystem")
Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: NJohan Hovold <johan@kernel.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 55570f1a
...@@ -235,7 +235,7 @@ struct gnss_device *gnss_allocate_device(struct device *parent) ...@@ -235,7 +235,7 @@ struct gnss_device *gnss_allocate_device(struct device *parent)
id = ida_simple_get(&gnss_minors, 0, GNSS_MINORS, GFP_KERNEL); id = ida_simple_get(&gnss_minors, 0, GNSS_MINORS, GFP_KERNEL);
if (id < 0) { if (id < 0) {
kfree(gdev); kfree(gdev);
return ERR_PTR(id); return NULL;
} }
gdev->id = id; gdev->id = id;
...@@ -270,7 +270,7 @@ struct gnss_device *gnss_allocate_device(struct device *parent) ...@@ -270,7 +270,7 @@ struct gnss_device *gnss_allocate_device(struct device *parent)
err_put_device: err_put_device:
put_device(dev); put_device(dev);
return ERR_PTR(-ENOMEM); return NULL;
} }
EXPORT_SYMBOL_GPL(gnss_allocate_device); EXPORT_SYMBOL_GPL(gnss_allocate_device);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册