summaryrefslogtreecommitdiff
path: root/arch/um
diff options
context:
space:
mode:
authorBenjamin Berg <benjamin.berg@intel.com>2023-02-09 12:00:02 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-03-11 15:55:22 +0300
commit4e774bf6ea50030dee58598c0fc2697a43409965 (patch)
tree6e166e6fa12ede068e324ec42deabfc6eae85b2f /arch/um
parent28ebc1164a45db27261ad8440dcbe9238beaf32a (diff)
downloadlinux-4e774bf6ea50030dee58598c0fc2697a43409965.tar.xz
um: virtio_uml: free command if adding to virtqueue failed
[ Upstream commit 8a6ca543646f2940832665dbf4e04105262505e2 ] If adding the command fails (i.e. the virtqueue is broken) then free it again if the function allocated a new buffer for it. Fixes: 68f5d3f3b654 ("um: add PCI over virtio emulation driver") Signed-off-by: Benjamin Berg <benjamin.berg@intel.com> Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'arch/um')
-rw-r--r--arch/um/drivers/virt-pci.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/arch/um/drivers/virt-pci.c b/arch/um/drivers/virt-pci.c
index 3ac220dafec4..3b637ad75ec8 100644
--- a/arch/um/drivers/virt-pci.c
+++ b/arch/um/drivers/virt-pci.c
@@ -132,8 +132,11 @@ static int um_pci_send_cmd(struct um_pci_device *dev,
out ? 1 : 0,
posted ? cmd : HANDLE_NO_FREE(cmd),
GFP_ATOMIC);
- if (ret)
+ if (ret) {
+ if (posted)
+ kfree(cmd);
goto out;
+ }
if (posted) {
virtqueue_kick(dev->cmd_vq);