diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2006-12-14 18:50:34 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-12-18 00:59:09 -0500 |
commit | 81dcd1690697efbdf8126e78fbbf7c76d359377f (patch) | |
tree | e4408697d6e40efed6f876b7bcd133fdc93c7eb5 | |
parent | 8d5cf596d10d740b69b5f4bbdb54b85abf75810d (diff) |
[AX.25]: Fix unchecked ax25_listen_register uses
Fix ax25_listen_register to return something that's a sane error code,
then all callers to use it.
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/ax25/ax25_iface.c | 7 | ||||
-rw-r--r-- | net/netrom/nr_dev.c | 24 | ||||
-rw-r--r-- | net/rose/af_rose.c | 3 |
3 files changed, 24 insertions, 10 deletions
diff --git a/net/ax25/ax25_iface.c b/net/ax25/ax25_iface.c index dd9b7fee3df8..51e293420b7f 100644 --- a/net/ax25/ax25_iface.c +++ b/net/ax25/ax25_iface.c | |||
@@ -154,7 +154,7 @@ int ax25_listen_register(ax25_address *callsign, struct net_device *dev) | |||
154 | return 0; | 154 | return 0; |
155 | 155 | ||
156 | if ((listen = kmalloc(sizeof(*listen), GFP_ATOMIC)) == NULL) | 156 | if ((listen = kmalloc(sizeof(*listen), GFP_ATOMIC)) == NULL) |
157 | return 0; | 157 | return -ENOMEM; |
158 | 158 | ||
159 | listen->callsign = *callsign; | 159 | listen->callsign = *callsign; |
160 | listen->dev = dev; | 160 | listen->dev = dev; |
@@ -164,7 +164,7 @@ int ax25_listen_register(ax25_address *callsign, struct net_device *dev) | |||
164 | listen_list = listen; | 164 | listen_list = listen; |
165 | spin_unlock_bh(&listen_lock); | 165 | spin_unlock_bh(&listen_lock); |
166 | 166 | ||
167 | return 1; | 167 | return 0; |
168 | } | 168 | } |
169 | 169 | ||
170 | EXPORT_SYMBOL(ax25_listen_register); | 170 | EXPORT_SYMBOL(ax25_listen_register); |
@@ -225,7 +225,8 @@ int ax25_listen_mine(ax25_address *callsign, struct net_device *dev) | |||
225 | 225 | ||
226 | spin_lock_bh(&listen_lock); | 226 | spin_lock_bh(&listen_lock); |
227 | for (listen = listen_list; listen != NULL; listen = listen->next) | 227 | for (listen = listen_list; listen != NULL; listen = listen->next) |
228 | if (ax25cmp(&listen->callsign, callsign) == 0 && (listen->dev == dev || listen->dev == NULL)) { | 228 | if (ax25cmp(&listen->callsign, callsign) == 0 && |
229 | (listen->dev == dev || listen->dev == NULL)) { | ||
229 | spin_unlock_bh(&listen_lock); | 230 | spin_unlock_bh(&listen_lock); |
230 | return 1; | 231 | return 1; |
231 | } | 232 | } |
diff --git a/net/netrom/nr_dev.c b/net/netrom/nr_dev.c index 9b8eb54971ab..4700d5225b78 100644 --- a/net/netrom/nr_dev.c +++ b/net/netrom/nr_dev.c | |||
@@ -128,25 +128,37 @@ static int nr_header(struct sk_buff *skb, struct net_device *dev, unsigned short | |||
128 | return -37; | 128 | return -37; |
129 | } | 129 | } |
130 | 130 | ||
131 | static int nr_set_mac_address(struct net_device *dev, void *addr) | 131 | static int __must_check nr_set_mac_address(struct net_device *dev, void *addr) |
132 | { | 132 | { |
133 | struct sockaddr *sa = addr; | 133 | struct sockaddr *sa = addr; |
134 | int err; | ||
135 | |||
136 | if (!memcmp(dev->dev_addr, sa->sa_data, dev->addr_len)) | ||
137 | return 0; | ||
138 | |||
139 | if (dev->flags & IFF_UP) { | ||
140 | err = ax25_listen_register((ax25_address *)sa->sa_data, NULL); | ||
141 | if (err) | ||
142 | return err; | ||
134 | 143 | ||
135 | if (dev->flags & IFF_UP) | ||
136 | ax25_listen_release((ax25_address *)dev->dev_addr, NULL); | 144 | ax25_listen_release((ax25_address *)dev->dev_addr, NULL); |
145 | } | ||
137 | 146 | ||
138 | memcpy(dev->dev_addr, sa->sa_data, dev->addr_len); | 147 | memcpy(dev->dev_addr, sa->sa_data, dev->addr_len); |
139 | 148 | ||
140 | if (dev->flags & IFF_UP) | ||
141 | ax25_listen_register((ax25_address *)dev->dev_addr, NULL); | ||
142 | |||
143 | return 0; | 149 | return 0; |
144 | } | 150 | } |
145 | 151 | ||
146 | static int nr_open(struct net_device *dev) | 152 | static int nr_open(struct net_device *dev) |
147 | { | 153 | { |
154 | int err; | ||
155 | |||
156 | err = ax25_listen_register((ax25_address *)dev->dev_addr, NULL); | ||
157 | if (err) | ||
158 | return err; | ||
159 | |||
148 | netif_start_queue(dev); | 160 | netif_start_queue(dev); |
149 | ax25_listen_register((ax25_address *)dev->dev_addr, NULL); | 161 | |
150 | return 0; | 162 | return 0; |
151 | } | 163 | } |
152 | 164 | ||
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c index 1605069e5db1..09f8a06bf806 100644 --- a/net/rose/af_rose.c +++ b/net/rose/af_rose.c | |||
@@ -1314,7 +1314,8 @@ static int rose_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
1314 | if (copy_from_user(&rose_callsign, argp, sizeof(ax25_address))) | 1314 | if (copy_from_user(&rose_callsign, argp, sizeof(ax25_address))) |
1315 | return -EFAULT; | 1315 | return -EFAULT; |
1316 | if (ax25cmp(&rose_callsign, &null_ax25_address) != 0) | 1316 | if (ax25cmp(&rose_callsign, &null_ax25_address) != 0) |
1317 | ax25_listen_register(&rose_callsign, NULL); | 1317 | return ax25_listen_register(&rose_callsign, NULL); |
1318 | |||
1318 | return 0; | 1319 | return 0; |
1319 | 1320 | ||
1320 | case SIOCRSGL2CALL: | 1321 | case SIOCRSGL2CALL: |