From d766e943905846806d99545bb66a5fd8ef0cbe8f Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Thu, 25 Sep 2003 12:40:42 -0400 Subject: [PATCH] [PATCH] (3/4) baycom/hdlcdrv unregister 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. --- drivers/net/hamradio/hdlcdrv.c | 4 +++- include/linux/hdlcdrv.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/hamradio/hdlcdrv.c b/drivers/net/hamradio/hdlcdrv.c index 349702f5a81a8..ca306b5b2f4b6 100644 --- a/drivers/net/hamradio/hdlcdrv.c +++ b/drivers/net/hamradio/hdlcdrv.c @@ -553,6 +553,7 @@ static int hdlcdrv_open(struct net_device *dev) /* * 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; @@ -592,6 +593,7 @@ static int hdlcdrv_close(struct net_device *dev) if (s->skb) dev_kfree_skb(s->skb); s->skb = NULL; + s->opened = 0; return i; } @@ -844,7 +846,7 @@ void hdlcdrv_unregister(struct net_device *dev) BUG_ON(s->magic != HDLCDRV_MAGIC); - if (s->ops->close) + if (s->opened && s->ops->close) s->ops->close(dev); unregister_netdev(dev); diff --git a/include/linux/hdlcdrv.h b/include/linux/hdlcdrv.h index bad91ec22db50..f824d306b7c60 100644 --- a/include/linux/hdlcdrv.h +++ b/include/linux/hdlcdrv.h @@ -180,6 +180,7 @@ struct hdlcdrv_ops { struct hdlcdrv_state { int magic; + int opened; const struct hdlcdrv_ops *ops; -- 2.53.0