diff options
author | Benjamin Berg <benjamin.berg@intel.com> | 2023-02-09 12:00:02 +0300 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2023-02-13 12:14:32 +0300 |
commit | 8a6ca543646f2940832665dbf4e04105262505e2 (patch) | |
tree | 9a09cf12984a511a2fdd10bdee9395300c2bf447 /arch/um/drivers | |
parent | b99ddbe8336ee680257c8ab479f75051eaa49dcf (diff) | |
download | linux-8a6ca543646f2940832665dbf4e04105262505e2.tar.xz |
um: virtio_uml: free command if adding to virtqueue failed
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>
Diffstat (limited to 'arch/um/drivers')
-rw-r--r-- | arch/um/drivers/virt-pci.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/arch/um/drivers/virt-pci.c b/arch/um/drivers/virt-pci.c index 2ba89347053a..035c97aadb38 100644 --- a/arch/um/drivers/virt-pci.c +++ b/arch/um/drivers/virt-pci.c @@ -137,8 +137,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); |