From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 219FCC6FA99 for ; Fri, 10 Mar 2023 14:07:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231717AbjCJOHR (ORCPT ); Fri, 10 Mar 2023 09:07:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231793AbjCJOGy (ORCPT ); Fri, 10 Mar 2023 09:06:54 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E622411A2E5 for ; Fri, 10 Mar 2023 06:06:27 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BCE1360F11 for ; Fri, 10 Mar 2023 14:06:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D219BC433D2; Fri, 10 Mar 2023 14:06:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1678457186; bh=XL/03RXm0WnyUahqdPAzHe12OCeHb+UjU+1NbW7TfMs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ri4xCtgfOQ1wldPlDYqGaND+uvQr+9eyQbugQSAVY/Sq3wVn8/jnXOvUpqkmyeRn8 p58LOPT93dnSTXBbEdTaR/Q9aItpa0iUP0OcbKV6ao6rY1zPIFXPDfdD/hGqUiolun TEuMwbgtmfn6zbf7hFbbUcz+of9Ynj765bEKBKrA= 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.1 049/200] um: virtio_uml: free command if adding to virtqueue failed Date: Fri, 10 Mar 2023 14:37:36 +0100 Message-Id: <20230310133718.605641928@linuxfoundation.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310133717.050159289@linuxfoundation.org> References: <20230310133717.050159289@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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