lkml.org 
[lkml]   [2018]   [Jul]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/2] gnss: fix potential error pointer dereference
Date
From: Dan Carpenter <dan.carpenter@oracle.com>

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 <dan.carpenter@oracle.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/gnss/core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gnss/core.c b/drivers/gnss/core.c
index f30ef8338b3a..4291a0dd22aa 100644
--- a/drivers/gnss/core.c
+++ b/drivers/gnss/core.c
@@ -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);

--
2.18.0
\
 
 \ /
  Last update: 2018-07-16 12:43    [W:0.036 / U:0.460 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site