[PATCH] ax25 setsockopt(SO_BINDTODEVICE) bug fix

From: Stephen Hemminger (kvypymlu@jat.de)
Date: Wed Aug 13 2003 - 03:19:26 EEST

  • Next message: Stephen Hemminger: "[PATCH] Convert ax25 to seq_file"

    Fix the error path (and indentation) in the SO_BINDTODEVICE setsockopt.
    As it was, a reference to the device was left hanging, and it would
    not check to see if the device was really an AX25 device.

    Found this with a simple test program on 2.6.0-test3 with your rqx4 patch.

    --- ax25/net/ax25/af_ax25.c 2003-08-12 17:08:42.025816088 -0700
    +++ linux-2.5-net/net/ax25/af_ax25.c 2003-08-12 16:47:07.802057749 -0700
                     if (optlen > IFNAMSIZ)
                             optlen=IFNAMSIZ;
                     if (copy_from_user(devname, optval, optlen)) {
    - res = -EFAULT;
    + res = -EFAULT;
                             break;
                     }
     
    @@ -650,12 +650,14 @@ static int ax25_setsockopt(struct socket
                        (sock->state != SS_UNCONNECTED ||
                         sk->sk_state == TCP_LISTEN)) {
                             res = -EADDRNOTAVAIL;
    - dev_put(dev);
    - break;
                     }
     
    - ax25->ax25_dev = ax25_dev_ax25dev(dev);
    - ax25_fillin_cb(ax25, ax25->ax25_dev);
    + else if ((ax25->ax25_dev = ax25_dev_ax25dev(dev)) == NULL)
    + res = -EINVAL;
    + else
    + ax25_fillin_cb(ax25, ax25->ax25_dev);
    +
    + dev_put(dev);
                     break;
     
             default:
    -
    To unsubscribe from this list: send the line "unsubscribe linux-hams" in
    the body of a message to jahg.zyndjsiwui@thn.ne.jp
    More majordomo info at http://vger.kernel.org/majordomo-info.html



    This archive was generated by hypermail 2b30 : Wed Aug 13 2003 - 03:19:58 EEST