Skip to content

Commit 8e4bbd2

Browse files
authored
Fix: fix segfault in st20_tx_queue_fatal_error (#1348)
Don't deallocated not existing frames when ST20_TYPE_RTP_LEVEL is used. Signed-off-by: Kasiewicz, Marek <[email protected]>
1 parent 3fb5a4b commit 8e4bbd2

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

lib/src/st2110/st_tx_video_session.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ static int tv_free_frames(struct st_tx_video_session_impl* s) {
246246

247247
mt_rte_free(s->st20_frames);
248248
s->st20_frames = NULL;
249+
s->st20_frames_cnt = 0; /* mark frames unavailable after free */
249250
}
250251

251252
dbg("%s(%d), succ\n", __func__, s->idx);
@@ -3910,16 +3911,18 @@ int st20_tx_queue_fatal_error(struct mtl_main_impl* impl,
39103911
uint16_t queue_id = mt_txq_queue_id(s->queue[s_port]);
39113912
info("%s(%d,%d), new queue_id %u\n", __func__, s_port, idx, queue_id);
39123913

3913-
/* cleanup frame manager */
3914-
struct st_frame_trans* frame;
3915-
for (uint16_t i = 0; i < s->st20_frames_cnt; i++) {
3916-
frame = &s->st20_frames[i];
3917-
int refcnt = rte_atomic32_read(&frame->refcnt);
3918-
if (refcnt) {
3919-
info("%s(%d,%d), stop frame %u\n", __func__, s_port, idx, i);
3920-
tv_notify_frame_done(s, i);
3921-
rte_atomic32_dec(&frame->refcnt);
3922-
rte_mbuf_ext_refcnt_set(&frame->sh_info, 0);
3914+
/* cleanup frame manager (only valid for frame-type sessions) */
3915+
if (st20_is_frame_type(s->ops.type)) {
3916+
struct st_frame_trans* frame;
3917+
for (uint16_t i = 0; i < s->st20_frames_cnt; i++) {
3918+
frame = &s->st20_frames[i];
3919+
int refcnt = rte_atomic32_read(&frame->refcnt);
3920+
if (refcnt) {
3921+
info("%s(%d,%d), stop frame %u\n", __func__, s_port, idx, i);
3922+
tv_notify_frame_done(s, i);
3923+
rte_atomic32_dec(&frame->refcnt);
3924+
rte_mbuf_ext_refcnt_set(&frame->sh_info, 0);
3925+
}
39233926
}
39243927
}
39253928

0 commit comments

Comments
 (0)