@@ -1025,7 +1025,7 @@ static u64 snd_compr_seqno_next(struct snd_compr_stream *stream)
1025
1025
static int snd_compr_task_new (struct snd_compr_stream * stream , struct snd_compr_task * utask )
1026
1026
{
1027
1027
struct snd_compr_task_runtime * task ;
1028
- int retval ;
1028
+ int retval , fd_i , fd_o ;
1029
1029
1030
1030
if (stream -> runtime -> total_tasks >= stream -> runtime -> fragments )
1031
1031
return - EBUSY ;
@@ -1039,16 +1039,24 @@ static int snd_compr_task_new(struct snd_compr_stream *stream, struct snd_compr_
1039
1039
retval = stream -> ops -> task_create (stream , task );
1040
1040
if (retval < 0 )
1041
1041
goto cleanup ;
1042
- utask -> input_fd = dma_buf_fd (task -> input , O_WRONLY |O_CLOEXEC );
1043
- if (utask -> input_fd < 0 ) {
1044
- retval = utask -> input_fd ;
1042
+ /* similar functionality as in dma_buf_fd(), but ensure that both
1043
+ file descriptors are allocated before fd_install() */
1044
+ if (!task -> input || !task -> input -> file || !task -> output || !task -> output -> file ) {
1045
+ retval = - EINVAL ;
1045
1046
goto cleanup ;
1046
1047
}
1047
- utask -> output_fd = dma_buf_fd (task -> output , O_RDONLY |O_CLOEXEC );
1048
- if (utask -> output_fd < 0 ) {
1049
- retval = utask -> output_fd ;
1048
+ fd_i = get_unused_fd_flags (O_WRONLY |O_CLOEXEC );
1049
+ if (fd_i < 0 )
1050
+ goto cleanup ;
1051
+ fd_o = get_unused_fd_flags (O_RDONLY |O_CLOEXEC );
1052
+ if (fd_o < 0 ) {
1053
+ put_unused_fd (fd_i );
1050
1054
goto cleanup ;
1051
1055
}
1056
+ fd_install (fd_i , task -> input -> file );
1057
+ fd_install (fd_o , task -> output -> file );
1058
+ utask -> input_fd = fd_i ;
1059
+ utask -> output_fd = fd_o ;
1052
1060
/* keep dmabuf reference until freed with task free ioctl */
1053
1061
dma_buf_get (utask -> input_fd );
1054
1062
dma_buf_get (utask -> output_fd );
0 commit comments