[capi] Update on thread safety for ml_tensors_info
authorParichay Kapoor <pk.kapoor@samsung.com>
Mon, 14 Jun 2021 07:01:21 +0000 (16:01 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Tue, 15 Jun 2021 12:06:19 +0000 (21:06 +0900)
commit0ecd8a3a608e4f870a05ba99391f779d13fc803a
treea3131c51e75d3fd21686c1bf27351e70417f131c
parent5d0d19073f5b5991f01fb130eaf128194f0ef3c7
[capi] Update on thread safety for ml_tensors_info

This patch fixes the case of Time of Check Time of Use bug in
ml_pipeline_custom_easy_filter_register().
The provided arguments `in` and `out` are first checked for validity
under their locks and then used for clone again under their locks.
However, between the two operations, both the variable are left lock
free, and the two variables can become invalid.
This patch adds the corresponding fix by adding support for
checking validity of ml_tensors_info_s lockfree which is done
under the lock acquired inside ml_tensors_info_clone().

Further, as a minor fix, redundant locking and unlocking
has been removed from ml_pipeline_custom_easy_filter_register().

See also #42 https://github.com/nnstreamer/api/pull/42#issuecomment-840265534
Resolves https://github.com/nnstreamer/nnstreamer/issues/2600

**Self evaluation:**
1. Build test: [x]Passed [ ]Failed [ ]Skipped
2. Run test: [x]Passed [ ]Failed [ ]Skipped

Signed-off-by: Parichay Kapoor <pk.kapoor@samsung.com>
c/include/nnstreamer-capi-private.h
c/src/nnstreamer-capi-pipeline.c
c/src/nnstreamer-capi-util.c