[PATCH] (3/4) baycom/hdlcdrv unregister

From
Stephen Hemminger <hidden>
Date
2003-09-19 20:38:04
Also in
linux-hams
If baycom driver has never been opened, it will attempt to free
an IRQ that it never registered when removed.  The problem is that hdlcdrv
does not keep track of open/close state.

diff -Nru a/drivers/net/hamradio/hdlcdrv.c b/drivers/net/hamradio/hdlcdrv.c
--- a/drivers/net/hamradio/hdlcdrv.c	Fri Sep 19 13:16:29 2003
+++ b/drivers/net/hamradio/hdlcdrv.c	Fri Sep 19 13:16:29 2003
@@ -554,6 +554,7 @@
 	/*
 	 * initialise some variables
 	 */
+	s->opened = 1;
 	s->hdlcrx.hbuf.rd = s->hdlcrx.hbuf.wr = 0;
 	s->hdlcrx.in_hdlc_rx = 0;
 	s->hdlcrx.rx_state = 0;
@@ -593,6 +594,7 @@
 	if (s->skb)
 		dev_kfree_skb(s->skb);
 	s->skb = NULL;
+	s->opened = 0;
 	return i;
 }
 
@@ -845,7 +847,7 @@
 
 	BUG_ON(s->magic != HDLCDRV_MAGIC);
 
-	if (s->ops->close)
+	if (s->opened && s->ops->close)
 		s->ops->close(dev);
 	unregister_netdev(dev);
 	
diff -Nru a/include/linux/hdlcdrv.h b/include/linux/hdlcdrv.h
--- a/include/linux/hdlcdrv.h	Fri Sep 19 13:16:29 2003
+++ b/include/linux/hdlcdrv.h	Fri Sep 19 13:16:29 2003
@@ -180,6 +180,7 @@
 
 struct hdlcdrv_state {
 	int magic;
+	int opened;
 
 	const struct hdlcdrv_ops *ops;
 
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help