From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C34D847F for ; Fri, 10 Mar 2023 13:56:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0267CC433D2; Fri, 10 Mar 2023 13:56:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1678456587; bh=XL/03RXm0WnyUahqdPAzHe12OCeHb+UjU+1NbW7TfMs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Uv+WLsf8w6QtgTQSlrLHhOnWwMJV+/XbeJFU5TE/Njl/lFTPFcVnglb1j0OcWy2Xk Uk2VGMxNQ/R7o17lmBP4OPwmapwF8aO/IUVLvHpeQOYKIUoKAtiMgsuxdU1cZJkK6Y a5wZvlTdR0pCdE3lkyg1mwe9cWtoqK2XMMNz1Xwc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Benjamin Berg , Richard Weinberger , Sasha Levin Subject: [PATCH 6.2 055/211] um: virtio_uml: free command if adding to virtqueue failed Date: Fri, 10 Mar 2023 14:37:15 +0100 Message-Id: <20230310133720.401027426@linuxfoundation.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310133718.689332661@linuxfoundation.org> References: <20230310133718.689332661@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Benjamin Berg [ 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 Signed-off-by: Richard Weinberger Signed-off-by: Sasha Levin --- 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 3ac220dafec4a..3b637ad75ec81 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.2