Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1384549 > unrolled thread
| Started by | Vladimir Zapolskiy <vz@mleia.com> |
|---|---|
| First post | 2016-04-21 22:10 +0200 |
| Last post | 2016-04-22 16:40 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] rapidio: fix potential NULL pointer dereference Vladimir Zapolskiy <vz@mleia.com> - 2016-04-21 22:10 +0200
RE: [PATCH] rapidio: fix potential NULL pointer dereference "Bounine, Alexandre" <Alexandre.Bounine@idt.com> - 2016-04-22 16:40 +0200
| From | Vladimir Zapolskiy <vz@mleia.com> |
|---|---|
| Date | 2016-04-21 22:10 +0200 |
| Subject | [PATCH] rapidio: fix potential NULL pointer dereference |
| Message-ID | <rqt5g-6Er-23@gated-at.bofh.it> |
The change fixes improper check for a returned error value by
class_create() function, which on error returns ERR_PTR() value,
thus the original check always results in a dead code on error path.
Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
---
drivers/rapidio/devices/rio_mport_cdev.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/rapidio/devices/rio_mport_cdev.c b/drivers/rapidio/devices/rio_mport_cdev.c
index 5d4d918..96168b8 100644
--- a/drivers/rapidio/devices/rio_mport_cdev.c
+++ b/drivers/rapidio/devices/rio_mport_cdev.c
@@ -2669,9 +2669,9 @@ static int __init mport_init(void)
/* Create device class needed by udev */
dev_class = class_create(THIS_MODULE, DRV_NAME);
- if (!dev_class) {
+ if (IS_ERR(dev_class)) {
rmcd_error("Unable to create " DRV_NAME " class");
- return -EINVAL;
+ return PTR_ERR(dev_class);
}
ret = alloc_chrdev_region(&dev_number, 0, RIO_MAX_MPORTS, DRV_NAME);
--
2.1.4
[toc] | [next] | [standalone]
| From | "Bounine, Alexandre" <Alexandre.Bounine@idt.com> |
|---|---|
| Date | 2016-04-22 16:40 +0200 |
| Message-ID | <rqKps-3oW-21@gated-at.bofh.it> |
| In reply to | #1384549 |
Thank you.
Ack-ed.
> -----Original Message-----
> From: Vladimir Zapolskiy [mailto:vz@mleia.com]
> Sent: Thursday, April 21, 2016 4:05 PM
> To: Matt Porter; Bounine, Alexandre
> Cc: linux-kernel@vger.kernel.org
> Subject: [PATCH] rapidio: fix potential NULL pointer dereference
>
> The change fixes improper check for a returned error value by
> class_create() function, which on error returns ERR_PTR() value,
> thus the original check always results in a dead code on error path.
>
> Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
> ---
> drivers/rapidio/devices/rio_mport_cdev.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/rapidio/devices/rio_mport_cdev.c
> b/drivers/rapidio/devices/rio_mport_cdev.c
> index 5d4d918..96168b8 100644
> --- a/drivers/rapidio/devices/rio_mport_cdev.c
> +++ b/drivers/rapidio/devices/rio_mport_cdev.c
> @@ -2669,9 +2669,9 @@ static int __init mport_init(void)
>
> /* Create device class needed by udev */
> dev_class = class_create(THIS_MODULE, DRV_NAME);
> - if (!dev_class) {
> + if (IS_ERR(dev_class)) {
> rmcd_error("Unable to create " DRV_NAME " class");
> - return -EINVAL;
> + return PTR_ERR(dev_class);
> }
>
> ret = alloc_chrdev_region(&dev_number, 0, RIO_MAX_MPORTS,
> DRV_NAME);
> --
> 2.1.4
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web