Skip to content

Commit

Permalink
Fix: pipeline mode API parameters check (#1045)
Browse files Browse the repository at this point in the history
Pipeline API for st20, st22, and st30 TX will
segfault when NULL parameters are passed to them.

Fix by adding a null guard that will return NULL
if any of the parameters are null

TODO: Tests for this cases and testing environment
for experimental st40 API as no testing is
implemented yet for this pipeline.
  • Loading branch information
DawidWesierski4 authored Jan 28, 2025
1 parent a5a80b4 commit c65e238
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/src/st2110/experimental/st40_pipeline_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,12 @@ st40p_tx_handle st40p_tx_create(mtl_handle mt, struct st40p_tx_ops* ops) {
enum mtl_port port;
int ret;

/* validate the input parameters */
if (!mt || !ops) {
err("%s(%d), NULL input parameters \n", __func__, idx);
return NULL;
}

notice("%s, start for %s\n", __func__, mt_string_safe(ops->name));

if (MT_HANDLE_MAIN != impl->type) {
Expand Down
9 changes: 8 additions & 1 deletion lib/src/st2110/pipeline/st20_pipeline_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -934,9 +934,16 @@ st20p_rx_handle st20p_rx_create(mtl_handle mt, struct st20p_rx_ops* ops) {
int ret;
int idx = st20p_rx_idx;
size_t dst_size = 0;
bool auto_detect = ops->flags & ST20P_RX_FLAG_AUTO_DETECT ? true : false;
bool auto_detect;

/* validate the input parameters */
if (!mt || !ops) {
err("%s(%d), NULL input parameters \n", __func__, idx);
return NULL;
}

notice("%s, start for %s\n", __func__, mt_string_safe(ops->name));
auto_detect = ops->flags & ST20P_RX_FLAG_AUTO_DETECT ? true : false;

if (impl->type != MT_HANDLE_MAIN) {
err("%s, invalid type %d\n", __func__, impl->type);
Expand Down
6 changes: 6 additions & 0 deletions lib/src/st2110/pipeline/st20_pipeline_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,12 @@ st20p_tx_handle st20p_tx_create(mtl_handle mt, struct st20p_tx_ops* ops) {
int idx = st20p_tx_idx;
size_t src_size;

/* validate the input parameters */
if (!mt || !ops) {
err("%s(%d), NULL input parameters \n", __func__, idx);
return NULL;
}

notice("%s, start for %s\n", __func__, mt_string_safe(ops->name));

if (impl->type != MT_HANDLE_MAIN) {
Expand Down
6 changes: 6 additions & 0 deletions lib/src/st2110/pipeline/st22_pipeline_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,12 @@ st22p_rx_handle st22p_rx_create(mtl_handle mt, struct st22p_rx_ops* ops) {
size_t dst_size;
enum st_frame_fmt codestream_fmt;

/* validate the input parameters */
if (!mt || !ops) {
err("%s(%d), NULL input parameters \n", __func__, idx);
return NULL;
}

notice("%s, start for %s\n", __func__, mt_string_safe(ops->name));

if (impl->type != MT_HANDLE_MAIN) {
Expand Down
6 changes: 6 additions & 0 deletions lib/src/st2110/pipeline/st22_pipeline_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,12 @@ st22p_tx_handle st22p_tx_create(mtl_handle mt, struct st22p_tx_ops* ops) {
size_t src_size;
enum st_frame_fmt codestream_fmt;

/* validate the input parameters */
if (!mt || !ops) {
err("%s(%d), NULL input parameters \n", __func__, idx);
return NULL;
}

notice("%s, start for %s\n", __func__, mt_string_safe(ops->name));

if (impl->type != MT_HANDLE_MAIN) {
Expand Down
6 changes: 6 additions & 0 deletions lib/src/st2110/pipeline/st30_pipeline_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,12 @@ st30p_rx_handle st30p_rx_create(mtl_handle mt, struct st30p_rx_ops* ops) {
int ret;
int idx = st30p_rx_idx;

/* validate the input parameters */
if (!mt || !ops) {
err("%s(%d), NULL input parameters \n", __func__, idx);
return NULL;
}

notice("%s, start for %s\n", __func__, mt_string_safe(ops->name));

if (impl->type != MT_HANDLE_MAIN) {
Expand Down
6 changes: 6 additions & 0 deletions lib/src/st2110/pipeline/st30_pipeline_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,12 @@ st30p_tx_handle st30p_tx_create(mtl_handle mt, struct st30p_tx_ops* ops) {
int ret;
int idx = st30p_tx_idx;

/* validate the input parameters */
if (!mt || !ops) {
err("%s(%d), NULL input parameters \n", __func__, idx);
return NULL;
}

notice("%s, start for %s\n", __func__, mt_string_safe(ops->name));

if (impl->type != MT_HANDLE_MAIN) {
Expand Down

0 comments on commit c65e238

Please sign in to comment.