Skip to content

Commit fb4a7c2

Browse files
ricmlifrankdjx
authored andcommitted
st/video: fix possible free of wild pointers (#237)
Signed-off-by: Ric Li <[email protected]> (cherry picked from commit 196e80f)
1 parent 3f41093 commit fb4a7c2

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

lib/src/st2110/st_tx_video_session.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,23 +1423,23 @@ static int tv_tasklet_frame(struct mtl_main_impl* impl,
14231423
}
14241424

14251425
if (!s->tx_no_chain) {
1426+
ret = rte_pktmbuf_alloc_bulk(chain_pool, pkts_chain, bulk);
1427+
if (ret < 0) {
1428+
dbg("%s(%d), pkts chain alloc fail %d\n", __func__, idx, ret);
1429+
rte_pktmbuf_free_bulk(pkts, bulk);
1430+
s->stat_build_ret_code = -STI_FRAME_PKT_ALLOC_FAIL;
1431+
return MT_TASKLET_ALL_DONE;
1432+
}
14261433
if (send_r) {
14271434
ret = rte_pktmbuf_alloc_bulk(hdr_pool_r, pkts_r, bulk);
14281435
if (ret < 0) {
14291436
dbg("%s(%d), pkts_r alloc fail %d\n", __func__, idx, ret);
14301437
rte_pktmbuf_free_bulk(pkts, bulk);
1438+
rte_pktmbuf_free_bulk(pkts_chain, bulk);
14311439
s->stat_build_ret_code = -STI_FRAME_PKT_ALLOC_FAIL;
14321440
return MT_TASKLET_ALL_DONE;
14331441
}
14341442
}
1435-
ret = rte_pktmbuf_alloc_bulk(chain_pool, pkts_chain, bulk);
1436-
if (ret < 0) {
1437-
dbg("%s(%d), pkts chain alloc fail %d\n", __func__, idx, ret);
1438-
rte_pktmbuf_free_bulk(pkts, bulk);
1439-
rte_pktmbuf_free_bulk(pkts_r, bulk);
1440-
s->stat_build_ret_code = -STI_FRAME_PKT_ALLOC_FAIL;
1441-
return MT_TASKLET_ALL_DONE;
1442-
}
14431443
}
14441444

14451445
for (unsigned int i = 0; i < bulk; i++) {
@@ -1828,23 +1828,23 @@ static int tv_tasklet_st22(struct mtl_main_impl* impl,
18281828
}
18291829

18301830
if (!s->tx_no_chain) {
1831+
ret = rte_pktmbuf_alloc_bulk(chain_pool, pkts_chain, bulk);
1832+
if (ret < 0) {
1833+
dbg("%s(%d), pkts chain alloc fail %d\n", __func__, idx, ret);
1834+
rte_pktmbuf_free_bulk(pkts, bulk);
1835+
s->stat_build_ret_code = -STI_FRAME_PKT_ALLOC_FAIL;
1836+
return MT_TASKLET_ALL_DONE;
1837+
}
18311838
if (send_r) {
18321839
ret = rte_pktmbuf_alloc_bulk(hdr_pool_r, pkts_r, bulk);
18331840
if (ret < 0) {
18341841
dbg("%s(%d), pkts_r alloc fail %d\n", __func__, idx, ret);
18351842
rte_pktmbuf_free_bulk(pkts, bulk);
1843+
rte_pktmbuf_free_bulk(pkts_chain, bulk);
18361844
s->stat_build_ret_code = -STI_FRAME_PKT_ALLOC_FAIL;
18371845
return MT_TASKLET_ALL_DONE;
18381846
}
18391847
}
1840-
ret = rte_pktmbuf_alloc_bulk(chain_pool, pkts_chain, bulk);
1841-
if (ret < 0) {
1842-
dbg("%s(%d), pkts chain alloc fail %d\n", __func__, idx, ret);
1843-
rte_pktmbuf_free_bulk(pkts, bulk);
1844-
rte_pktmbuf_free_bulk(pkts_r, bulk);
1845-
s->stat_build_ret_code = -STI_FRAME_PKT_ALLOC_FAIL;
1846-
return MT_TASKLET_ALL_DONE;
1847-
}
18481848
}
18491849

18501850
for (unsigned int i = 0; i < bulk; i++) {

0 commit comments

Comments
 (0)