--- zzzz-none-000/linux-2.6.39.4/net/socket.c 2011-08-03 19:43:28.000000000 +0000 +++ puma6-arm-6490-729/linux-2.6.39.4/net/socket.c 2021-11-10 13:23:11.000000000 +0000 @@ -966,6 +966,7 @@ void __user *argp = (void __user *)arg; int pid, err; struct net *net; + unsigned long tc_index; sock = file->private_data; sk = sock->sk; @@ -1026,6 +1027,19 @@ err = dlci_ioctl_hook(cmd, argp); mutex_unlock(&dlci_ioctl_mutex); break; + + case SIOCSET_TC_INDEX: + err = -EFAULT; + if (get_user(tc_index, (unsigned long __user *)argp)) + break; + sock->sk->sk_tc_index = tc_index; + err = 0; + break; + + case SIOCGET_TC_INDEX: + err = put_user(sock->sk->sk_tc_index, (unsigned long __user *)argp); + break; + default: err = sock_do_ioctl(net, sock, cmd, arg); break; @@ -2110,8 +2124,10 @@ return err; err = sock_error(sock->sk); - if (err) + if (err) { + datagrams = err; goto out_put; + } entry = mmsg; compat_entry = (struct compat_mmsghdr __user *)mmsg; @@ -2164,31 +2180,31 @@ break; } -out_put: - fput_light(sock->file, fput_needed); - if (err == 0) - return datagrams; + goto out_put; + + if (datagrams == 0) { + datagrams = err; + goto out_put; + } - if (datagrams != 0) { + /* + * We may return less entries than requested (vlen) if the + * sock is non block and there aren't enough datagrams... + */ + if (err != -EAGAIN) { /* - * We may return less entries than requested (vlen) if the - * sock is non block and there aren't enough datagrams... + * ... or if recvmsg returns an error after we + * received some datagrams, where we record the + * error to return on the next call or if the + * app asks about it using getsockopt(SO_ERROR). */ - if (err != -EAGAIN) { - /* - * ... or if recvmsg returns an error after we - * received some datagrams, where we record the - * error to return on the next call or if the - * app asks about it using getsockopt(SO_ERROR). - */ - sock->sk->sk_err = -err; - } - - return datagrams; + sock->sk->sk_err = -err; } +out_put: + fput_light(sock->file, fput_needed); - return err; + return datagrams; } SYSCALL_DEFINE5(recvmmsg, int, fd, struct mmsghdr __user *, mmsg,