File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed
Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -799,8 +799,11 @@ static void __virtio_snd_frame_dequeue(void *out,
799799
800800 written_bytes += len ;
801801 node -> pos += len ;
802- if (node -> pos >= node -> len )
802+ if (node -> pos >= node -> len ) {
803803 list_del (& node -> q );
804+ free (node -> addr );
805+ free (node );
806+ }
804807 }
805808
806809 props -> lock .buf_ev_notify -- ;
@@ -929,15 +932,20 @@ static void __virtio_snd_frame_enqueue(void *payload,
929932 * [2]
930933 * https://github.com/rust-vmm/vhost-device/blob/eb2e2227e41d48a52e4e6346189b772c5363879d/staging/vhost-device-sound/src/device.rs#L554
931934 */
932- /* FIXME: locate the root case of repeating artifact even we
933- * keep the pointer of the payload.
934- */
935935 vsnd_buf_queue_node_t * node = malloc (sizeof (* node ));
936- node -> addr = payload ;
936+ if (!node )
937+ goto tx_frame_enqueue_final ;
938+ node -> addr = malloc (sizeof (* node -> addr ) * n );
939+ if (!node -> addr ) {
940+ free (node );
941+ goto tx_frame_enqueue_final ;
942+ }
943+ memcpy (node -> addr , payload , n );
937944 node -> len = n ;
938945 node -> pos = 0 ;
939946 list_push (& node -> q , & props -> buf_queue_head );
940947
948+ tx_frame_enqueue_final :
941949 pthread_mutex_unlock (& props -> lock .lock );
942950}
943951
You can’t perform that action at this time.
0 commit comments