aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-05-12 06:29:11 -0400
committerDavid S. Miller <davem@davemloft.net>2008-05-12 06:29:11 -0400
commit4951704b4e23d71b99ac933d8e6993bc6225ac13 (patch)
treeafcc69d6ec071f5d0bb19517635e9b3cf8f668ba
parentc4492586a618d18e8a5343a04bad0ec606064846 (diff)
syncppp: Fix crashes.
The syncppp layer wants a mid-level netdev private pointer. It was using netdev->priv but that only worked by accident, and thus this scheme was broken when the device private allocation strategy changed. Add a proper mid-layer private pointer for uses like this, update syncppp and all users, and remove the HDLC_PPP broken tag from drivers/net/wan/Kconfig Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/wan/Kconfig4
-rw-r--r--drivers/net/wan/cosa.c14
-rw-r--r--drivers/net/wan/hdlc_ppp.c2
-rw-r--r--drivers/net/wan/hostess_sv11.c12
-rw-r--r--drivers/net/wan/lmc/lmc_main.c1
-rw-r--r--drivers/net/wan/sealevel.c1
-rw-r--r--include/linux/netdevice.h3
-rw-r--r--include/net/syncppp.h2
8 files changed, 21 insertions, 18 deletions
diff --git a/drivers/net/wan/Kconfig b/drivers/net/wan/Kconfig
index 8005dd16fb4e..d5140aed7b79 100644
--- a/drivers/net/wan/Kconfig
+++ b/drivers/net/wan/Kconfig
@@ -150,11 +150,9 @@ config HDLC_FR
150 150
151config HDLC_PPP 151config HDLC_PPP
152 tristate "Synchronous Point-to-Point Protocol (PPP) support" 152 tristate "Synchronous Point-to-Point Protocol (PPP) support"
153 depends on HDLC && BROKEN 153 depends on HDLC
154 help 154 help
155 Generic HDLC driver supporting PPP over WAN connections. 155 Generic HDLC driver supporting PPP over WAN connections.
156 This module is currently broken and will cause a kernel panic
157 when a device configured in PPP mode is activated.
158 156
159 It will be replaced by new PPP implementation in Linux 2.6.26. 157 It will be replaced by new PPP implementation in Linux 2.6.26.
160 158
diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
index 45ddfc9763cc..b0fce1387eaf 100644
--- a/drivers/net/wan/cosa.c
+++ b/drivers/net/wan/cosa.c
@@ -629,7 +629,7 @@ static void sppp_channel_init(struct channel_data *chan)
629 d->base_addr = chan->cosa->datareg; 629 d->base_addr = chan->cosa->datareg;
630 d->irq = chan->cosa->irq; 630 d->irq = chan->cosa->irq;
631 d->dma = chan->cosa->dma; 631 d->dma = chan->cosa->dma;
632 d->priv = chan; 632 d->ml_priv = chan;
633 sppp_attach(&chan->pppdev); 633 sppp_attach(&chan->pppdev);
634 if (register_netdev(d)) { 634 if (register_netdev(d)) {
635 printk(KERN_WARNING "%s: register_netdev failed.\n", d->name); 635 printk(KERN_WARNING "%s: register_netdev failed.\n", d->name);
@@ -650,7 +650,7 @@ static void sppp_channel_delete(struct channel_data *chan)
650 650
651static int cosa_sppp_open(struct net_device *d) 651static int cosa_sppp_open(struct net_device *d)
652{ 652{
653 struct channel_data *chan = d->priv; 653 struct channel_data *chan = d->ml_priv;
654 int err; 654 int err;
655 unsigned long flags; 655 unsigned long flags;
656 656
@@ -690,7 +690,7 @@ static int cosa_sppp_open(struct net_device *d)
690 690
691static int cosa_sppp_tx(struct sk_buff *skb, struct net_device *dev) 691static int cosa_sppp_tx(struct sk_buff *skb, struct net_device *dev)
692{ 692{
693 struct channel_data *chan = dev->priv; 693 struct channel_data *chan = dev->ml_priv;
694 694
695 netif_stop_queue(dev); 695 netif_stop_queue(dev);
696 696
@@ -701,7 +701,7 @@ static int cosa_sppp_tx(struct sk_buff *skb, struct net_device *dev)
701 701
702static void cosa_sppp_timeout(struct net_device *dev) 702static void cosa_sppp_timeout(struct net_device *dev)
703{ 703{
704 struct channel_data *chan = dev->priv; 704 struct channel_data *chan = dev->ml_priv;
705 705
706 if (test_bit(RXBIT, &chan->cosa->rxtx)) { 706 if (test_bit(RXBIT, &chan->cosa->rxtx)) {
707 chan->stats.rx_errors++; 707 chan->stats.rx_errors++;
@@ -720,7 +720,7 @@ static void cosa_sppp_timeout(struct net_device *dev)
720 720
721static int cosa_sppp_close(struct net_device *d) 721static int cosa_sppp_close(struct net_device *d)
722{ 722{
723 struct channel_data *chan = d->priv; 723 struct channel_data *chan = d->ml_priv;
724 unsigned long flags; 724 unsigned long flags;
725 725
726 netif_stop_queue(d); 726 netif_stop_queue(d);
@@ -800,7 +800,7 @@ static int sppp_tx_done(struct channel_data *chan, int size)
800 800
801static struct net_device_stats *cosa_net_stats(struct net_device *dev) 801static struct net_device_stats *cosa_net_stats(struct net_device *dev)
802{ 802{
803 struct channel_data *chan = dev->priv; 803 struct channel_data *chan = dev->ml_priv;
804 return &chan->stats; 804 return &chan->stats;
805} 805}
806 806
@@ -1217,7 +1217,7 @@ static int cosa_sppp_ioctl(struct net_device *dev, struct ifreq *ifr,
1217 int cmd) 1217 int cmd)
1218{ 1218{
1219 int rv; 1219 int rv;
1220 struct channel_data *chan = dev->priv; 1220 struct channel_data *chan = dev->ml_priv;
1221 rv = cosa_ioctl_common(chan->cosa, chan, cmd, (unsigned long)ifr->ifr_data); 1221 rv = cosa_ioctl_common(chan->cosa, chan, cmd, (unsigned long)ifr->ifr_data);
1222 if (rv == -ENOIOCTLCMD) { 1222 if (rv == -ENOIOCTLCMD) {
1223 return sppp_do_ioctl(dev, ifr, cmd); 1223 return sppp_do_ioctl(dev, ifr, cmd);
diff --git a/drivers/net/wan/hdlc_ppp.c b/drivers/net/wan/hdlc_ppp.c
index 10396d9686f4..00308337928e 100644
--- a/drivers/net/wan/hdlc_ppp.c
+++ b/drivers/net/wan/hdlc_ppp.c
@@ -45,7 +45,7 @@ static int ppp_open(struct net_device *dev)
45 int (*old_ioctl)(struct net_device *, struct ifreq *, int); 45 int (*old_ioctl)(struct net_device *, struct ifreq *, int);
46 int result; 46 int result;
47 47
48 dev->priv = &state(hdlc)->syncppp_ptr; 48 dev->ml_priv = &state(hdlc)->syncppp_ptr;
49 state(hdlc)->syncppp_ptr = &state(hdlc)->pppdev; 49 state(hdlc)->syncppp_ptr = &state(hdlc)->pppdev;
50 state(hdlc)->pppdev.dev = dev; 50 state(hdlc)->pppdev.dev = dev;
51 51
diff --git a/drivers/net/wan/hostess_sv11.c b/drivers/net/wan/hostess_sv11.c
index 83dbc924fcb5..f3065d3473fd 100644
--- a/drivers/net/wan/hostess_sv11.c
+++ b/drivers/net/wan/hostess_sv11.c
@@ -75,7 +75,7 @@ static void hostess_input(struct z8530_channel *c, struct sk_buff *skb)
75 75
76static int hostess_open(struct net_device *d) 76static int hostess_open(struct net_device *d)
77{ 77{
78 struct sv11_device *sv11=d->priv; 78 struct sv11_device *sv11=d->ml_priv;
79 int err = -1; 79 int err = -1;
80 80
81 /* 81 /*
@@ -128,7 +128,7 @@ static int hostess_open(struct net_device *d)
128 128
129static int hostess_close(struct net_device *d) 129static int hostess_close(struct net_device *d)
130{ 130{
131 struct sv11_device *sv11=d->priv; 131 struct sv11_device *sv11=d->ml_priv;
132 /* 132 /*
133 * Discard new frames 133 * Discard new frames
134 */ 134 */
@@ -159,14 +159,14 @@ static int hostess_close(struct net_device *d)
159 159
160static int hostess_ioctl(struct net_device *d, struct ifreq *ifr, int cmd) 160static int hostess_ioctl(struct net_device *d, struct ifreq *ifr, int cmd)
161{ 161{
162 /* struct sv11_device *sv11=d->priv; 162 /* struct sv11_device *sv11=d->ml_priv;
163 z8530_ioctl(d,&sv11->sync.chanA,ifr,cmd) */ 163 z8530_ioctl(d,&sv11->sync.chanA,ifr,cmd) */
164 return sppp_do_ioctl(d, ifr,cmd); 164 return sppp_do_ioctl(d, ifr,cmd);
165} 165}
166 166
167static struct net_device_stats *hostess_get_stats(struct net_device *d) 167static struct net_device_stats *hostess_get_stats(struct net_device *d)
168{ 168{
169 struct sv11_device *sv11=d->priv; 169 struct sv11_device *sv11=d->ml_priv;
170 if(sv11) 170 if(sv11)
171 return z8530_get_stats(&sv11->sync.chanA); 171 return z8530_get_stats(&sv11->sync.chanA);
172 else 172 else
@@ -179,7 +179,7 @@ static struct net_device_stats *hostess_get_stats(struct net_device *d)
179 179
180static int hostess_queue_xmit(struct sk_buff *skb, struct net_device *d) 180static int hostess_queue_xmit(struct sk_buff *skb, struct net_device *d)
181{ 181{
182 struct sv11_device *sv11=d->priv; 182 struct sv11_device *sv11=d->ml_priv;
183 return z8530_queue_xmit(&sv11->sync.chanA, skb); 183 return z8530_queue_xmit(&sv11->sync.chanA, skb);
184} 184}
185 185
@@ -325,6 +325,7 @@ static struct sv11_device *sv11_init(int iobase, int irq)
325 /* 325 /*
326 * Initialise the PPP components 326 * Initialise the PPP components
327 */ 327 */
328 d->ml_priv = sv;
328 sppp_attach(&sv->netdev); 329 sppp_attach(&sv->netdev);
329 330
330 /* 331 /*
@@ -333,7 +334,6 @@ static struct sv11_device *sv11_init(int iobase, int irq)
333 334
334 d->base_addr = iobase; 335 d->base_addr = iobase;
335 d->irq = irq; 336 d->irq = irq;
336 d->priv = sv;
337 337
338 if(register_netdev(d)) 338 if(register_netdev(d))
339 { 339 {
diff --git a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c
index 6635ecef36e5..62133cee446a 100644
--- a/drivers/net/wan/lmc/lmc_main.c
+++ b/drivers/net/wan/lmc/lmc_main.c
@@ -891,6 +891,7 @@ static int __devinit lmc_init_one(struct pci_dev *pdev,
891 891
892 /* Initialize the sppp layer */ 892 /* Initialize the sppp layer */
893 /* An ioctl can cause a subsequent detach for raw frame interface */ 893 /* An ioctl can cause a subsequent detach for raw frame interface */
894 dev->ml_priv = sc;
894 sc->if_type = LMC_PPP; 895 sc->if_type = LMC_PPP;
895 sc->check = 0xBEAFCAFE; 896 sc->check = 0xBEAFCAFE;
896 dev->base_addr = pci_resource_start(pdev, 0); 897 dev->base_addr = pci_resource_start(pdev, 0);
diff --git a/drivers/net/wan/sealevel.c b/drivers/net/wan/sealevel.c
index 11276bf3149f..44a89df1b8bf 100644
--- a/drivers/net/wan/sealevel.c
+++ b/drivers/net/wan/sealevel.c
@@ -241,6 +241,7 @@ static inline struct slvl_device *slvl_alloc(int iobase, int irq)
241 return NULL; 241 return NULL;
242 242
243 sv = d->priv; 243 sv = d->priv;
244 d->ml_priv = sv;
244 sv->if_ptr = &sv->pppdev; 245 sv->if_ptr = &sv->pppdev;
245 sv->pppdev.dev = d; 246 sv->pppdev.dev = d;
246 d->base_addr = iobase; 247 d->base_addr = iobase;
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 7c1d4466583b..746901774d49 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -715,6 +715,9 @@ struct net_device
715 struct net *nd_net; 715 struct net *nd_net;
716#endif 716#endif
717 717
718 /* mid-layer private */
719 void *ml_priv;
720
718 /* bridge stuff */ 721 /* bridge stuff */
719 struct net_bridge_port *br_port; 722 struct net_bridge_port *br_port;
720 /* macvlan */ 723 /* macvlan */
diff --git a/include/net/syncppp.h b/include/net/syncppp.h
index 877efa434700..e43f4070d892 100644
--- a/include/net/syncppp.h
+++ b/include/net/syncppp.h
@@ -59,7 +59,7 @@ struct ppp_device
59 59
60static inline struct sppp *sppp_of(struct net_device *dev) 60static inline struct sppp *sppp_of(struct net_device *dev)
61{ 61{
62 struct ppp_device **ppp = dev->priv; 62 struct ppp_device **ppp = dev->ml_priv;
63 BUG_ON((*ppp)->dev != dev); 63 BUG_ON((*ppp)->dev != dev);
64 return &(*ppp)->sppp; 64 return &(*ppp)->sppp;
65} 65}