qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

audio: fix wavcapture segfault

Commit 571a8c522e caused the HMP wavcapture command to segfault when
processing audio data in audio_pcm_sw_write(), where a NULL
sw->hw->pcm_ops is dereferenced. This fix checks that the pointer is
valid before dereferincing it. A similar fix is also made in the
parallel function audio_pcm_sw_read().

Fixes: 571a8c522e (audio: split ctl_* functions into enable_* and
volume_*)
Signed-off-by: Bruce Rogers <brogers@suse.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20200521172931.121903-1-brogers@suse.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>

authored by

Bruce Rogers and committed by
Gerd Hoffmann
cbaf25d1 9c61fcc8

+2 -2
+2 -2
audio/audio.c
··· 649 649 total += isamp; 650 650 } 651 651 652 - if (!hw->pcm_ops->volume_in) { 652 + if (hw->pcm_ops && !hw->pcm_ops->volume_in) { 653 653 mixeng_volume (sw->buf, ret, &sw->vol); 654 654 } 655 655 ··· 736 736 if (swlim) { 737 737 sw->conv (sw->buf, buf, swlim); 738 738 739 - if (!sw->hw->pcm_ops->volume_out) { 739 + if (sw->hw->pcm_ops && !sw->hw->pcm_ops->volume_out) { 740 740 mixeng_volume (sw->buf, swlim, &sw->vol); 741 741 } 742 742 }