| .. | .. |
|---|
| 682 | 682 | return 0; |
|---|
| 683 | 683 | } |
|---|
| 684 | 684 | |
|---|
| 685 | | -static int |
|---|
| 686 | | -clonefd(struct file *filp) |
|---|
| 687 | | -{ |
|---|
| 688 | | - int ret; |
|---|
| 689 | | - ret = get_unused_fd_flags(0); |
|---|
| 690 | | - if (ret >= 0) { |
|---|
| 691 | | - get_file(filp); |
|---|
| 692 | | - fd_install(ret, filp); |
|---|
| 693 | | - } |
|---|
| 694 | | - |
|---|
| 695 | | - return ret; |
|---|
| 696 | | -} |
|---|
| 697 | | - |
|---|
| 698 | 685 | #ifdef ENABLE_ASYNC |
|---|
| 699 | 686 | /* enqueue a job for asynchronous completion |
|---|
| 700 | 687 | * |
|---|
| .. | .. |
|---|
| 961 | 948 | case CIOCASYMFEAT: |
|---|
| 962 | 949 | return put_user(0, p); |
|---|
| 963 | 950 | case CRIOGET: |
|---|
| 964 | | - fd = clonefd(filp); |
|---|
| 951 | + fd = get_unused_fd_flags(0); |
|---|
| 952 | + if (unlikely(fd < 0)) |
|---|
| 953 | + return fd; |
|---|
| 954 | + |
|---|
| 965 | 955 | ret = put_user(fd, p); |
|---|
| 966 | 956 | if (unlikely(ret)) { |
|---|
| 967 | | -#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 17, 0)) |
|---|
| 968 | | - sys_close(fd); |
|---|
| 969 | | -#elif (LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0)) |
|---|
| 970 | | - ksys_close(fd); |
|---|
| 971 | | -#else |
|---|
| 972 | | - close_fd(fd); |
|---|
| 973 | | -#endif |
|---|
| 957 | + put_unused_fd(fd); |
|---|
| 974 | 958 | return ret; |
|---|
| 975 | 959 | } |
|---|
| 960 | + |
|---|
| 961 | + get_file(filp); |
|---|
| 962 | + fd_install(fd, filp); |
|---|
| 963 | + |
|---|
| 976 | 964 | return ret; |
|---|
| 977 | 965 | case CIOCGSESSION: |
|---|
| 978 | 966 | if (unlikely(copy_from_user(&sop, arg, sizeof(sop)))) |
|---|