Commit 81dcd169 authored by Ralf Baechle's avatar Ralf Baechle Committed by David S. Miller

[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: default avatarRalf Baechle <ralf@linux-mips.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8d5cf596
...@@ -154,7 +154,7 @@ int ax25_listen_register(ax25_address *callsign, struct net_device *dev) ...@@ -154,7 +154,7 @@ int ax25_listen_register(ax25_address *callsign, struct net_device *dev)
return 0; return 0;
if ((listen = kmalloc(sizeof(*listen), GFP_ATOMIC)) == NULL) if ((listen = kmalloc(sizeof(*listen), GFP_ATOMIC)) == NULL)
return 0; return -ENOMEM;
listen->callsign = *callsign; listen->callsign = *callsign;
listen->dev = dev; listen->dev = dev;
...@@ -164,7 +164,7 @@ int ax25_listen_register(ax25_address *callsign, struct net_device *dev) ...@@ -164,7 +164,7 @@ int ax25_listen_register(ax25_address *callsign, struct net_device *dev)
listen_list = listen; listen_list = listen;
spin_unlock_bh(&listen_lock); spin_unlock_bh(&listen_lock);
return 1; return 0;
} }
EXPORT_SYMBOL(ax25_listen_register); EXPORT_SYMBOL(ax25_listen_register);
...@@ -225,7 +225,8 @@ int ax25_listen_mine(ax25_address *callsign, struct net_device *dev) ...@@ -225,7 +225,8 @@ int ax25_listen_mine(ax25_address *callsign, struct net_device *dev)
spin_lock_bh(&listen_lock); spin_lock_bh(&listen_lock);
for (listen = listen_list; listen != NULL; listen = listen->next) for (listen = listen_list; listen != NULL; listen = listen->next)
if (ax25cmp(&listen->callsign, callsign) == 0 && (listen->dev == dev || listen->dev == NULL)) { if (ax25cmp(&listen->callsign, callsign) == 0 &&
(listen->dev == dev || listen->dev == NULL)) {
spin_unlock_bh(&listen_lock); spin_unlock_bh(&listen_lock);
return 1; return 1;
} }
......
...@@ -128,25 +128,37 @@ static int nr_header(struct sk_buff *skb, struct net_device *dev, unsigned short ...@@ -128,25 +128,37 @@ static int nr_header(struct sk_buff *skb, struct net_device *dev, unsigned short
return -37; return -37;
} }
static int nr_set_mac_address(struct net_device *dev, void *addr) static int __must_check nr_set_mac_address(struct net_device *dev, void *addr)
{ {
struct sockaddr *sa = addr; struct sockaddr *sa = addr;
int err;
if (!memcmp(dev->dev_addr, sa->sa_data, dev->addr_len))
return 0;
if (dev->flags & IFF_UP) {
err = ax25_listen_register((ax25_address *)sa->sa_data, NULL);
if (err)
return err;
if (dev->flags & IFF_UP)
ax25_listen_release((ax25_address *)dev->dev_addr, NULL); ax25_listen_release((ax25_address *)dev->dev_addr, NULL);
}
memcpy(dev->dev_addr, sa->sa_data, dev->addr_len); memcpy(dev->dev_addr, sa->sa_data, dev->addr_len);
if (dev->flags & IFF_UP)
ax25_listen_register((ax25_address *)dev->dev_addr, NULL);
return 0; return 0;
} }
static int nr_open(struct net_device *dev) static int nr_open(struct net_device *dev)
{ {
int err;
err = ax25_listen_register((ax25_address *)dev->dev_addr, NULL);
if (err)
return err;
netif_start_queue(dev); netif_start_queue(dev);
ax25_listen_register((ax25_address *)dev->dev_addr, NULL);
return 0; return 0;
} }
......
...@@ -1314,7 +1314,8 @@ static int rose_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) ...@@ -1314,7 +1314,8 @@ static int rose_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
if (copy_from_user(&rose_callsign, argp, sizeof(ax25_address))) if (copy_from_user(&rose_callsign, argp, sizeof(ax25_address)))
return -EFAULT; return -EFAULT;
if (ax25cmp(&rose_callsign, &null_ax25_address) != 0) if (ax25cmp(&rose_callsign, &null_ax25_address) != 0)
ax25_listen_register(&rose_callsign, NULL); return ax25_listen_register(&rose_callsign, NULL);
return 0; return 0;
case SIOCRSGL2CALL: case SIOCRSGL2CALL:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment