[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC PATCH 13/27] virtio-snd: Add VIRTIO_SND_R_JACK_INFO handler
From: |
Gerd Hoffmann |
Subject: |
Re: [RFC PATCH 13/27] virtio-snd: Add VIRTIO_SND_R_JACK_INFO handler |
Date: |
Fri, 30 Apr 2021 12:13:32 +0200 |
Hi,
> + virtio_snd_query_info req;
> + size_t sz = iov_to_buf(elem->out_sg, elem->out_num, 0, &req,
> sizeof(req));
> + assert(sz == sizeof(virtio_snd_query_info));
This assert looks like the guest can trigger it by sending broken
messages. This should be avoided, the guest should not be able to
kill qemu that way.
> + jack_info[i - req.start_id].hdr.hda_fn_nid = jack->hda_fn_nid;
> + jack_info[i - req.start_id].features = jack->features;
> + jack_info[i - req.start_id].hda_reg_defconf = jack->hda_reg_defconf;
> + jack_info[i - req.start_id].hda_reg_caps = jack->hda_reg_caps;
> + jack_info[i - req.start_id].connected = jack->connected;
Disclaimer: didn't check the structs.
If any of these fields is larger than a byte you need to take care of
byte ordering here. virtio is little endian, so cpu_to_le{16,32}() will
do the job here (if needed).
Same thing elsewhere I suspect.
> } else if (ctrl.code == VIRTIO_SND_R_JACK_INFO) {
> - virtio_snd_log("VIRTIO_SND_R_JACK_INFO");
> + sz = virtio_snd_handle_jack_info(s, elem);
> + goto done;
Ah, you add the actual command handing here. Hmm. I guess a tracepoint
in virtio_snd_handle_jack_info() would be good for debugging. You could
also log the jack id then.
Also: I'd suggest using "switch(ctrl.code)" here. Is more readable than
else-if chains (personal opinion though). Also has the advantage that
gcc will warn in case you forget to handle one of the enums in the
switch.
take care,
Gerd
- [RFC PATCH 07/27] virtio-snd: Add properties for class init, (continued)
- [RFC PATCH 07/27] virtio-snd: Add properties for class init, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 08/27] virtio-snd: Add code for get config function, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 09/27] virtio-snd: Add code for set config function, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 10/27] virtio-snd: Add code for the realize function, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 12/27] virtio-snd: Add control virtqueue handler, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 11/27] virtio-snd: Add macros for logging, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 13/27] virtio-snd: Add VIRTIO_SND_R_JACK_INFO handler, Shreyansh Chouhan, 2021/04/29
- Re: [RFC PATCH 13/27] virtio-snd: Add VIRTIO_SND_R_JACK_INFO handler,
Gerd Hoffmann <=
- [RFC PATCH 15/27] virtio-snd: Add VIRTIO_SND_R_PCM_INFO handler, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 14/27] virtio-snd: Add stub for VIRTIO_SND_R_JACK_REMAP handler, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 18/27] virtio-snd: Add default configs to realize fn, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 16/27] virtio-snd: Add VIRITO_SND_R_PCM_SET_PARAMS handle, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 21/27] virtio-snd: Add VIRTIO_SND_R_PCM_STOP handler, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 20/27] virtio-snd: Add VIRITO_SND_R_PCM_START handler, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 17/27] virtio-snd: Add VIRTIO_SND_R_PCM_PREPARE handler, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 19/27] virtio-snd: Add callback for SWVoiceOut, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 23/27] virtio-snd: Replaced goto with if else, Shreyansh Chouhan, 2021/04/29