* [PATCH] gnss: fix potential error pointer dereference
@ 2018-07-03 11:59 Dan Carpenter
2018-07-03 12:11 ` Johan Hovold
0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2018-07-03 11:59 UTC (permalink / raw)
To: Johan Hovold; +Cc: linux-kernel, kernel-janitors
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: 10f146639fee ("gnss: add receiver type support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
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);
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] gnss: fix potential error pointer dereference
2018-07-03 11:59 [PATCH] gnss: fix potential error pointer dereference Dan Carpenter
@ 2018-07-03 12:11 ` Johan Hovold
2018-07-03 12:23 ` Dan Carpenter
2018-07-03 12:25 ` [PATCH v2] " Dan Carpenter
0 siblings, 2 replies; 4+ messages in thread
From: Johan Hovold @ 2018-07-03 12:11 UTC (permalink / raw)
To: Dan Carpenter, Greg Kroah-Hartman
Cc: Johan Hovold, linux-kernel, kernel-janitors
On Tue, Jul 03, 2018 at 02:59:22PM +0300, Dan Carpenter wrote:
> 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: 10f146639fee ("gnss: add receiver type support")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Ouch, thanks for catching this!
I think you got the wrong commit for the fixes tag above, however. That
should be:
Fixes: 2b6a44035143 ("gnss: add GNSS receiver subsystem")
Not sure if you want to send a v2, or if Greg can fix that when
applying. Apart from that:
Acked-by: Johan Hovold <johan@kernel.org>
Johan
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] gnss: fix potential error pointer dereference
2018-07-03 12:11 ` Johan Hovold
@ 2018-07-03 12:23 ` Dan Carpenter
2018-07-03 12:25 ` [PATCH v2] " Dan Carpenter
1 sibling, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2018-07-03 12:23 UTC (permalink / raw)
To: Johan Hovold; +Cc: Greg Kroah-Hartman, linux-kernel, kernel-janitors
On Tue, Jul 03, 2018 at 02:11:43PM +0200, Johan Hovold wrote:
> On Tue, Jul 03, 2018 at 02:59:22PM +0300, Dan Carpenter wrote:
> > 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: 10f146639fee ("gnss: add receiver type support")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> Ouch, thanks for catching this!
>
> I think you got the wrong commit for the fixes tag above, however. That
> should be:
>
> Fixes: 2b6a44035143 ("gnss: add GNSS receiver subsystem")
>
Oops. That's what I intended, yes. I will resend.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH v2] gnss: fix potential error pointer dereference
2018-07-03 12:11 ` Johan Hovold
2018-07-03 12:23 ` Dan Carpenter
@ 2018-07-03 12:25 ` Dan Carpenter
1 sibling, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2018-07-03 12:25 UTC (permalink / raw)
To: Johan Hovold; +Cc: linux-kernel, kernel-janitors
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>
Acked-by: Johan Hovold <johan@kernel.org>
---
v2: Use the correct Fixes tag.
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);
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-07-03 12:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-03 11:59 [PATCH] gnss: fix potential error pointer dereference Dan Carpenter
2018-07-03 12:11 ` Johan Hovold
2018-07-03 12:23 ` Dan Carpenter
2018-07-03 12:25 ` [PATCH v2] " Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox