Skip to content

Commit e1b7aa4

Browse files
Fix: pipeline mode API parameters check
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.
1 parent 8dad8fb commit e1b7aa4

7 files changed

+42
-0
lines changed

lib/src/st2110/experimental/st40_pipeline_tx.c

+6
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,12 @@ st40p_tx_handle st40p_tx_create(mtl_handle mt, struct st40p_tx_ops* ops) {
441441

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

444+
/* validate the input parameters */
445+
if (!mt || !ops) {
446+
err("%s(%d), NULL input parameters \n", __func__, idx);
447+
return NULL;
448+
}
449+
444450
if (MT_HANDLE_MAIN != impl->type) {
445451
err("%s, invalid type %d\n", __func__, impl->type);
446452
return NULL;

lib/src/st2110/pipeline/st20_pipeline_rx.c

+6
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,12 @@ st20p_rx_handle st20p_rx_create(mtl_handle mt, struct st20p_rx_ops* ops) {
938938

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

941+
/* validate the input parameters */
942+
if (!mt || !ops) {
943+
err("%s(%d), NULL input parameters \n", __func__, idx);
944+
return NULL;
945+
}
946+
941947
if (impl->type != MT_HANDLE_MAIN) {
942948
err("%s, invalid type %d\n", __func__, impl->type);
943949
return NULL;

lib/src/st2110/pipeline/st20_pipeline_tx.c

+6
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,12 @@ st20p_tx_handle st20p_tx_create(mtl_handle mt, struct st20p_tx_ops* ops) {
783783

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

786+
/* validate the input parameters */
787+
if (!mt || !ops) {
788+
err("%s(%d), NULL input parameters \n", __func__, idx);
789+
return NULL;
790+
}
791+
786792
if (impl->type != MT_HANDLE_MAIN) {
787793
err("%s, invalid type %d\n", __func__, impl->type);
788794
return NULL;

lib/src/st2110/pipeline/st22_pipeline_rx.c

+6
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,12 @@ st22p_rx_handle st22p_rx_create(mtl_handle mt, struct st22p_rx_ops* ops) {
657657

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

660+
/* validate the input parameters */
661+
if (!mt || !ops) {
662+
err("%s(%d), NULL input parameters \n", __func__, idx);
663+
return NULL;
664+
}
665+
660666
if (impl->type != MT_HANDLE_MAIN) {
661667
err("%s, invalid type %d\n", __func__, impl->type);
662668
return NULL;

lib/src/st2110/pipeline/st22_pipeline_tx.c

+6
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,12 @@ st22p_tx_handle st22p_tx_create(mtl_handle mt, struct st22p_tx_ops* ops) {
783783

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

786+
/* validate the input parameters */
787+
if (!mt || !ops) {
788+
err("%s(%d), NULL input parameters \n", __func__, idx);
789+
return NULL;
790+
}
791+
786792
if (impl->type != MT_HANDLE_MAIN) {
787793
err("%s, invalid type %d\n", __func__, impl->type);
788794
return NULL;

lib/src/st2110/pipeline/st30_pipeline_rx.c

+6
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,12 @@ st30p_rx_handle st30p_rx_create(mtl_handle mt, struct st30p_rx_ops* ops) {
393393

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

396+
/* validate the input parameters */
397+
if (!mt || !ops) {
398+
err("%s(%d), NULL input parameters \n", __func__, idx);
399+
return NULL;
400+
}
401+
396402
if (impl->type != MT_HANDLE_MAIN) {
397403
err("%s, invalid type %d\n", __func__, impl->type);
398404
return NULL;

lib/src/st2110/pipeline/st30_pipeline_tx.c

+6
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,12 @@ st30p_tx_handle st30p_tx_create(mtl_handle mt, struct st30p_tx_ops* ops) {
470470

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

473+
/* validate the input parameters */
474+
if (!mt || !ops) {
475+
err("%s(%d), NULL input parameters \n", __func__, idx);
476+
return NULL;
477+
}
478+
473479
if (impl->type != MT_HANDLE_MAIN) {
474480
err("%s, invalid type %d\n", __func__, impl->type);
475481
return NULL;

0 commit comments

Comments
 (0)