Patchwork caif: fix NULL pointer check

login
register
mail settings
Submitter Alan Cox
Date July 24, 2012, 12:42 p.m.
Message ID <20120724124207.4444.49789.stgit@localhost.localdomain>
Download mbox | patch
Permalink /patch/172862/
State Accepted
Delegated to: David Miller
Headers show

Comments

Alan Cox - July 24, 2012, 12:42 p.m.
From: Alan Cox <alan@linux.intel.com>

Reported-by: <rucsoftsec@gmail.com>
Resolves-bug: http://bugzilla.kernel.org/show_bug?44441
Signed-off-by: Alan Cox <alan@linux.intel.com>
---

 drivers/net/caif/caif_serial.c |    3 +++
 1 file changed, 3 insertions(+)


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - July 24, 2012, 8:57 p.m.
From: Alan Cox <alan@lxorguk.ukuu.org.uk>
Date: Tue, 24 Jul 2012 13:42:14 +0100

> From: Alan Cox <alan@linux.intel.com>
> 
> Reported-by: <rucsoftsec@gmail.com>
> Resolves-bug: http://bugzilla.kernel.org/show_bug?44441
> Signed-off-by: Alan Cox <alan@linux.intel.com>

Applied and queued up for -stable.

> +	if (dev == NULL)

I adjusted this to be "if (!dev)"
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/net/caif/caif_serial.c b/drivers/net/caif/caif_serial.c
index 8a3054b..7e84175 100644
--- a/drivers/net/caif/caif_serial.c
+++ b/drivers/net/caif/caif_serial.c
@@ -325,6 +325,9 @@  static int ldisc_open(struct tty_struct *tty)
 
 	sprintf(name, "cf%s", tty->name);
 	dev = alloc_netdev(sizeof(*ser), name, caifdev_setup);
+	if (dev == NULL)
+		return -ENOMEM;
+
 	ser = netdev_priv(dev);
 	ser->tty = tty_kref_get(tty);
 	ser->dev = dev;