aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2009-09-28 15:26:28 -0400
committerDavid S. Miller <davem@davemloft.net>2009-09-28 15:26:28 -0400
commit2f72291d3d0e440f9343c7b97dc233c1a122165a (patch)
treef2cdcf5bfd4b44387751c6339cf996e8ef455559 /net
parentd1f8297a96b0d70f17704296a6666468f2087ce6 (diff)
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>
Diffstat (limited to 'net')
-rw-r--r--net/ax25/af_ax25.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
index fbcac76fdc0d..4102de1022ee 100644
--- a/net/ax25/af_ax25.c
+++ b/net/ax25/af_ax25.c
@@ -641,15 +641,10 @@ static int ax25_setsockopt(struct socket *sock, int level, int optname,
641 641
642 case SO_BINDTODEVICE: 642 case SO_BINDTODEVICE:
643 if (optlen > IFNAMSIZ) 643 if (optlen > IFNAMSIZ)
644 optlen=IFNAMSIZ; 644 optlen = IFNAMSIZ;
645 if (copy_from_user(devname, optval, optlen)) {
646 res = -EFAULT;
647 break;
648 }
649 645
650 dev = dev_get_by_name(&init_net, devname); 646 if (copy_from_user(devname, optval, optlen)) {
651 if (dev == NULL) { 647 res = -EFAULT;
652 res = -ENODEV;
653 break; 648 break;
654 } 649 }
655 650
@@ -657,12 +652,18 @@ static int ax25_setsockopt(struct socket *sock, int level, int optname,
657 (sock->state != SS_UNCONNECTED || 652 (sock->state != SS_UNCONNECTED ||
658 sk->sk_state == TCP_LISTEN)) { 653 sk->sk_state == TCP_LISTEN)) {
659 res = -EADDRNOTAVAIL; 654 res = -EADDRNOTAVAIL;
660 dev_put(dev); 655 break;
656 }
657
658 dev = dev_get_by_name(&init_net, devname);
659 if (!dev) {
660 res = -ENODEV;
661 break; 661 break;
662 } 662 }
663 663
664 ax25->ax25_dev = ax25_dev_ax25dev(dev); 664 ax25->ax25_dev = ax25_dev_ax25dev(dev);
665 ax25_fillin_cb(ax25, ax25->ax25_dev); 665 ax25_fillin_cb(ax25, ax25->ax25_dev);
666 dev_put(dev);
666 break; 667 break;
667 668
668 default: 669 default: