Patchwork CAIF: write check

login
register
mail settings
Submitter Alan Cox
Date April 7, 2010, 1:17 p.m.
Message ID <20100407141703.7c0a4a65@lxorguk.ukuu.org.uk>
Download mbox | patch
Permalink /patch/49605/
State Accepted
Delegated to: David Miller
Headers show

Comments

Alan Cox - April 7, 2010, 1:17 p.m.
caif: check write operations

From: Alan Cox <alan@linux.intel.com>

write is optional for a tty device. Check that we have a write op rather
than calling NULL.

Signed-off-by: Alan Cox <alan@linux.intel.com>
---

 drivers/net/caif/caif_serial.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)



--
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 - April 7, 2010, 11:49 p.m.
From: Alan Cox <alan@lxorguk.ukuu.org.uk>
Date: Wed, 7 Apr 2010 14:17:03 +0100

> caif: check write operations
> 
> From: Alan Cox <alan@linux.intel.com>
> 
> write is optional for a tty device. Check that we have a write op rather
> than calling NULL.
> 
> Signed-off-by: Alan Cox <alan@linux.intel.com>

Applied, thanks Alan.
--
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 b271aa0..38c0186 100644
--- a/drivers/net/caif/caif_serial.c
+++ b/drivers/net/caif/caif_serial.c
@@ -312,6 +312,10 @@  static int ldisc_open(struct tty_struct *tty)
 	char name[64];
 	int result;
 
+	/* No write no play */
+	if (tty->ops->write == NULL)
+		return -EOPNOTSUPP;
+
 	sprintf(name, "cf%s", tty->name);
 	dev = alloc_netdev(sizeof(*ser), name, caifdev_setup);
 	ser = netdev_priv(dev);