History

dnn/dnn_backend_native_layer_conv2d: Check thread creation for errors

Fixes Coverity issue #1473533.

Andreas Rheinhardt committed 5 years ago

Commit 9da96d81 parent c2fef8f1 file · +10 −3Browse files

Unified · Split

libavfilter/dnn/dnn_backend_native_layer_conv2d.c+10−3
@@ -190,7 +190,7 @@ int ff_dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_opera · 189 unmodified lines
190190 #if HAVE_PTHREAD_CANCEL
191191 int thread_num = (ctx->options.conv2d_threads <= 0 || ctx->options.conv2d_threads > av_cpu_count())
192192 ? (av_cpu_count() + 1) : (ctx->options.conv2d_threads);
193− int thread_stride;
193+ int ret = DNN_SUCCESS, thread_stride;
194194 ThreadParam *thread_param;
195195 #else
196196 ThreadParam thread_param = { 0 };
@@ -236,7 +236,12 @@ int ff_dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_opera · 39 unmodified lines
236236 thread_param[i].thread_common_param = &thread_common_param;
237237 thread_param[i].thread_start = thread_stride * i + pad_size;
238238 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+ }
240245 }
241246
242247 //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
246251
247252 //release memory
248253 av_freep(&thread_param);
254+
255+ return ret;
249256 #else
250257 thread_param.thread_common_param = &thread_common_param;
251258 thread_param.thread_start = pad_size;
252259 thread_param.thread_end = height - pad_size;
253260 dnn_execute_layer_conv2d_thread(&thread_param);
254−#endif
255261
256262 return DNN_SUCCESS;
263+#endif
257264 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t