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

Showing the changes to libavfilter (1 of 1 file). Show all

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
190#if HAVE_PTHREAD_CANCEL190#if HAVE_PTHREAD_CANCEL
191 int thread_num = (ctx->options.conv2d_threads <= 0 || ctx->options.conv2d_threads > av_cpu_count())191 int thread_num = (ctx->options.conv2d_threads <= 0 || ctx->options.conv2d_threads > av_cpu_count())
192 ? (av_cpu_count() + 1) : (ctx->options.conv2d_threads);192 ? (av_cpu_count() + 1) : (ctx->options.conv2d_threads);
193 int thread_stride;193 int ret = DNN_SUCCESS, thread_stride;
194 ThreadParam *thread_param;194 ThreadParam *thread_param;
195#else195#else
196 ThreadParam thread_param = { 0 };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 thread_param[i].thread_common_param = &thread_common_param;236 thread_param[i].thread_common_param = &thread_common_param;
237 thread_param[i].thread_start = thread_stride * i + pad_size;237 thread_param[i].thread_start = thread_stride * i + pad_size;
238 thread_param[i].thread_end = (i == thread_num - 1) ? (height - pad_size) : (thread_param[i].thread_start + thread_stride);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 //join threads, res gets function return247 //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 //release memory252 //release memory
248 av_freep(&thread_param);253 av_freep(&thread_param);
254
255 return ret;
249#else256#else
250 thread_param.thread_common_param = &thread_common_param;257 thread_param.thread_common_param = &thread_common_param;
251 thread_param.thread_start = pad_size;258 thread_param.thread_start = pad_size;
252 thread_param.thread_end = height - pad_size;259 thread_param.thread_end = height - pad_size;
253 dnn_execute_layer_conv2d_thread(&thread_param);260 dnn_execute_layer_conv2d_thread(&thread_param);
254#endif
255 261
256 return DNN_SUCCESS;262 return DNN_SUCCESS;
263#endif
257}264}

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