When snd_hdsp_load_firmware_from_cache and snd_hdsp_enable_io fails,
the hdsp->fw_uploaded needs to be free.Or there could be memleaks in
snd_hdsp_hwdep_ioctl.
Fixes: 90caaef6a1ce ("ALSA: hdsp: improve firmware caching")
Signed-off-by: Zhipeng Lu <alexious@xxxxxxxxxx>
---
Changelog:
v2: remove label 'err' which is unused.
---
sound/pci/rme9652/hdsp.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
index e7d1b43471a2..b83b0c484f8e 100644
--- a/sound/pci/rme9652/hdsp.c
+++ b/sound/pci/rme9652/hdsp.c
@@ -4874,21 +4874,20 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne
if (copy_from_user(hdsp->fw_uploaded, firmware_data,
HDSP_FIRMWARE_SIZE)) {
- vfree(hdsp->fw_uploaded);
- hdsp->fw_uploaded = NULL;
- return -EFAULT;
+ err = -EFAULT;
+ goto free_fw_uploaded;
}
hdsp->state |= HDSP_FirmwareCached;
err = snd_hdsp_load_firmware_from_cache(hdsp);
if (err < 0)
- return err;
+ goto free_fw_uploaded;
if (!(hdsp->state & HDSP_InitializationComplete)) {
err = snd_hdsp_enable_io(hdsp);
if (err < 0)
- return err;
+ goto free_fw_uploaded;
snd_hdsp_initialize_channels(hdsp);
snd_hdsp_initialize_midi_flush(hdsp);
@@ -4897,7 +4896,7 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne
if (err < 0) {
dev_err(hdsp->card->dev,
"error creating alsa devices\n");
- return err;
+ goto free_fw_uploaded;
}
}
break;
@@ -4912,6 +4911,11 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne
return -EINVAL;
}
return 0;
+
+free_fw_uploaded:
+ vfree(hdsp->fw_uploaded);
+ hdsp->fw_uploaded = NULL;
+ return err;
}
static const struct snd_pcm_ops snd_hdsp_playback_ops = {
--
2.34.1
[Index of Archives]
[Pulseaudio]
[Linux Audio Users]
[ALSA Devel]
[Fedora Desktop]
[Fedora SELinux]
[Big List of Linux Books]
[Yosemite News]
[KDE Users]