summaryrefslogtreecommitdiff
path: root/sound/virtio
diff options
context:
space:
mode:
Diffstat (limited to 'sound/virtio')
-rw-r--r--sound/virtio/virtio_kctl.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/sound/virtio/virtio_kctl.c b/sound/virtio/virtio_kctl.c
index 0c6ac74aca1e..7aa79c05b464 100644
--- a/sound/virtio/virtio_kctl.c
+++ b/sound/virtio/virtio_kctl.c
@@ -253,8 +253,8 @@ static int virtsnd_kctl_tlv_op(struct snd_kcontrol *kcontrol, int op_flag,
tlv = kzalloc(size, GFP_KERNEL);
if (!tlv) {
- virtsnd_ctl_msg_unref(msg);
- return -ENOMEM;
+ rc = -ENOMEM;
+ goto on_msg_unref;
}
sg_init_one(&sg, tlv, size);
@@ -281,14 +281,25 @@ static int virtsnd_kctl_tlv_op(struct snd_kcontrol *kcontrol, int op_flag,
hdr->hdr.code =
cpu_to_le32(VIRTIO_SND_R_CTL_TLV_COMMAND);
- if (copy_from_user(tlv, utlv, size))
+ if (copy_from_user(tlv, utlv, size)) {
rc = -EFAULT;
- else
+ goto on_msg_unref;
+ } else {
rc = virtsnd_ctl_msg_send(snd, msg, &sg, NULL, false);
+ }
break;
+ default:
+ rc = -EINVAL;
+ /* We never get here - we listed all values for op_flag */
+ WARN_ON(1);
+ goto on_msg_unref;
}
+ kfree(tlv);
+ return rc;
+on_msg_unref:
+ virtsnd_ctl_msg_unref(msg);
kfree(tlv);
return rc;