ax25: Add missing dev_put in ax25_setsockopt
ax25_setsockopt SO_BINDTODEVICE is missing a dev_put call in case of success. Re-order code to fix this bug. While at it also reformat two lines of code to comply with the Linux coding style. Initial patch by Jarek Poplawski <jarkao2@gmail.com>. Reported-by: Bernard Pidoux F6BVP <f6bvp@free.fr> Signed-off-by: Ralf Baechle <ralf@linux-mips.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Родитель
d1f8297a96
Коммит
2f72291d3d
|
@ -642,27 +642,28 @@ static int ax25_setsockopt(struct socket *sock, int level, int optname,
|
||||||
case SO_BINDTODEVICE:
|
case SO_BINDTODEVICE:
|
||||||
if (optlen > IFNAMSIZ)
|
if (optlen > IFNAMSIZ)
|
||||||
optlen = IFNAMSIZ;
|
optlen = IFNAMSIZ;
|
||||||
|
|
||||||
if (copy_from_user(devname, optval, optlen)) {
|
if (copy_from_user(devname, optval, optlen)) {
|
||||||
res = -EFAULT;
|
res = -EFAULT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev = dev_get_by_name(&init_net, devname);
|
|
||||||
if (dev == NULL) {
|
|
||||||
res = -ENODEV;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sk->sk_type == SOCK_SEQPACKET &&
|
if (sk->sk_type == SOCK_SEQPACKET &&
|
||||||
(sock->state != SS_UNCONNECTED ||
|
(sock->state != SS_UNCONNECTED ||
|
||||||
sk->sk_state == TCP_LISTEN)) {
|
sk->sk_state == TCP_LISTEN)) {
|
||||||
res = -EADDRNOTAVAIL;
|
res = -EADDRNOTAVAIL;
|
||||||
dev_put(dev);
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
dev = dev_get_by_name(&init_net, devname);
|
||||||
|
if (!dev) {
|
||||||
|
res = -ENODEV;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ax25->ax25_dev = ax25_dev_ax25dev(dev);
|
ax25->ax25_dev = ax25_dev_ax25dev(dev);
|
||||||
ax25_fillin_cb(ax25, ax25->ax25_dev);
|
ax25_fillin_cb(ax25, ax25->ax25_dev);
|
||||||
|
dev_put(dev);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
Загрузка…
Ссылка в новой задаче