Fixes Coverity issue #1473533.
Unified · Split
| @@ -190,7 +190,7 @@ int ff_dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_opera · 189 unmodified lines | ||
| 190 | 190 | #if HAVE_PTHREAD_CANCEL |
| 191 | 191 | int thread_num = (ctx->options.conv2d_threads <= 0 || ctx->options.conv2d_threads > av_cpu_count()) |
| 192 | 192 | ? (av_cpu_count() + 1) : (ctx->options.conv2d_threads); |
| 193 | − int thread_stride; | |
| 193 | + int ret = DNN_SUCCESS, thread_stride; | |
| 194 | 194 | ThreadParam *thread_param; |
| 195 | 195 | #else |
| 196 | 196 | ThreadParam thread_param = { 0 }; |
| @@ -236,7 +236,12 @@ int ff_dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_opera · 39 unmodified lines | ||
| 236 | 236 | thread_param[i].thread_common_param = &thread_common_param; |
| 237 | 237 | thread_param[i].thread_start = thread_stride * i + pad_size; |
| 238 | 238 | thread_param[i].thread_end = (i == thread_num - 1) ? (height - pad_size) : (thread_param[i].thread_start + thread_stride); |
| 239 | − pthread_create(&thread_param[i].thread, NULL, dnn_execute_layer_conv2d_thread, &thread_param[i]); | |
| 239 | + if (pthread_create(&thread_param[i].thread, NULL, | |
| 240 | + dnn_execute_layer_conv2d_thread, &thread_param[i])) { | |
| 241 | + thread_num = i; | |
| 242 | + ret = DNN_ERROR; | |
| 243 | + break; | |
| 244 | + } | |
| 240 | 245 | } |
| 241 | 246 | |
| 242 | 247 | //join threads, res gets function return |
| @@ -246,12 +251,14 @@ int ff_dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_opera · 3 unmodified lines | ||
| 246 | 251 | |
| 247 | 252 | //release memory |
| 248 | 253 | av_freep(&thread_param); |
| 254 | + | |
| 255 | + return ret; | |
| 249 | 256 | #else |
| 250 | 257 | thread_param.thread_common_param = &thread_common_param; |
| 251 | 258 | thread_param.thread_start = pad_size; |
| 252 | 259 | thread_param.thread_end = height - pad_size; |
| 253 | 260 | dnn_execute_layer_conv2d_thread(&thread_param); |
| 254 | −#endif | |
| 255 | 261 | |
| 256 | 262 | return DNN_SUCCESS; |
| 263 | +#endif | |
| 257 | 264 | } |