linux-um.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] um: virtio_uml: free command if adding to virtqueue failed
@ 2023-02-09  9:00 benjamin
  2023-02-09  9:00 ` [PATCH 2/4] um: virtio_uml: mark device as unregistered when breaking it benjamin
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: benjamin @ 2023-02-09  9:00 UTC (permalink / raw)
  To: linux-um; +Cc: Benjamin Berg

From: Benjamin Berg <benjamin.berg@intel.com>

If adding the command fails (i.e. the virtqueue is broken) then free it
again if the function allocated a new buffer for it.

Change-Id: I03d2c687aeccb8bc8da280925ffdaeb8fb70eee7
Fixes: 68f5d3f3b654 ("um: add PCI over virtio emulation driver")
Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
---
 arch/um/drivers/virt-pci.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

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);
-- 
2.39.1


_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-02-09  9:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-09  9:00 [PATCH 1/4] um: virtio_uml: free command if adding to virtqueue failed benjamin
2023-02-09  9:00 ` [PATCH 2/4] um: virtio_uml: mark device as unregistered when breaking it benjamin
2023-02-09  9:00 ` [PATCH 3/4] um: virtio_uml: move device breaking into workqueue benjamin
2023-02-09  9:00 ` [PATCH 4/4] um: virt-pci: properly remove PCI device from bus benjamin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).