From patchwork Tue Jun 14 19:06:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 1643395 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=Gy3D0Sj2; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LMybl5K8Tz9vFN for ; Wed, 15 Jun 2022 05:06:59 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1o1BsJ-0007mb-Tj; Tue, 14 Jun 2022 19:06:51 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1o1Bs4-0007N8-Et for kernel-team@lists.ubuntu.com; Tue, 14 Jun 2022 19:06:36 +0000 Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 4500B3F4B7 for ; Tue, 14 Jun 2022 19:06:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1655233594; bh=WMnJ2T1gyVuoNn1HeGPlOiLhd0NnjkFDCofW+Pq9e/o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Gy3D0Sj2hpWxLb4HIvv9S9HJAFuLMozITUkGtfVotAgeHEtk0LyCh6lfe9vg7OdbS mXMaZXW8b8VdRc888cJzWDsOpqfTuvh02MiwoxwUUmrY7zGyl3JK/5LzYs1bNX2TNr B8KXEYXn8EXUC2ZFwVkyYBl6l9QM8CzL2CIM6j4twxTWXGM8bkEEF06WadlBNTpyyM 88iE751BPobBvt2gjY1eTzIsCfmRZQswwgnmvZW7USJ+fqX3oteIp22TDpG93SSRdg tyctI3Wf2jDvABv1pi1ggdm9dVQWpDe9a5KeUqmHuqDhAy8sYepXC5g5Wh24NS+yQw 9cfCAHwdgVKQQ== Received: by mail-pf1-f199.google.com with SMTP id z5-20020aa79f85000000b0051baa4e9fb8so4201145pfr.7 for ; Tue, 14 Jun 2022 12:06:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WMnJ2T1gyVuoNn1HeGPlOiLhd0NnjkFDCofW+Pq9e/o=; b=Weo7imyhACiYh+b5hqPThMzr2MBKmNDmDPIq1z57U76yfWdflYWZO/iO3iFv/Ci/Gn z29eab8SG+0QNmadDO6THEFS3fgffyasuDgB7SZU/I4pmFWG3ZKkNozKkz9HkDyn2SGJ YtPfbxfTG2T/KbgOhmKe+2rrz37V7yQYFGQ822PmW3mQ/BZ9gBJ5AEEbaatb+1795x9P g8guTsdA1O/uiIdpXwZ4bEMCyNUZma0hh8luV15HtQMJ0QlGP1lJ5btt+LZIyVydAohq VIsJ3sr+t+Y+GTi/xdQa+GhOY40x3L5K7WlYyYQYR1xOGYNTNu4r+tbPN+RCBIIVT4xh f3ow== X-Gm-Message-State: AOAM5329VAl5P34xo9zBktDMZaAZciPSY3IcxTHWeKE0R8x0N2pOMbca KErxr0qtbkGuVGN5RiX87dRxu3c+Yfsk+TpMVGt7CjgTqgZXeYpJf71zJR5+/uBOH0ju/NQjKsD FTQB1a2/FOI2AWZv+YNTIfOH0sTLAPrP2qnYC5Q3FyA== X-Received: by 2002:a05:6a00:338e:b0:51b:c452:4210 with SMTP id cm14-20020a056a00338e00b0051bc4524210mr5765751pfb.69.1655233591658; Tue, 14 Jun 2022 12:06:31 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vaUTbSuGIrcy2Po3CrtuyO4cKsyRzvHsTUxCeiMM2hbxzBrCGRKjz4k6IcE2wvj/2fQG/tYQ== X-Received: by 2002:a05:6a00:338e:b0:51b:c452:4210 with SMTP id cm14-20020a056a00338e00b0051bc4524210mr5765736pfb.69.1655233591344; Tue, 14 Jun 2022 12:06:31 -0700 (PDT) Received: from localhost.localdomain ([69.163.84.166]) by smtp.gmail.com with ESMTPSA id c15-20020a62f84f000000b0051ba97b788bsm2293090pfm.27.2022.06.14.12.06.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jun 2022 12:06:30 -0700 (PDT) From: Tim Gardner To: kernel-team@lists.ubuntu.com Subject: [PATCH 09/13] VMCI: Fix some error handling paths in vmci_guest_probe_device() Date: Tue, 14 Jun 2022 13:06:14 -0600 Message-Id: <20220614190618.15053-10-tim.gardner@canonical.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220614190618.15053-1-tim.gardner@canonical.com> References: <20220614190618.15053-1-tim.gardner@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Christophe JAILLET BugLink: https://bugs.launchpad.net/bugs/1978145 The 'err_remove_vmci_dev_g' error label is not at the right place. This could lead to un-released resource. There is also a missing label. If pci_alloc_irq_vectors() fails, the previous vmci_event_subscribe() call must be undone. Acked-by: Vishnu Dasa Signed-off-by: Christophe JAILLET Link: https://lore.kernel.org/r/959218ce3b135197946d85cd9453551cd04fa5da.1645734041.git.christophe.jaillet@wanadoo.fr Signed-off-by: Greg Kroah-Hartman (cherry picked from commit 77e861619baea5a7c934e47fda74b03c0b072aec) Signed-off-by: Tim Gardner --- drivers/misc/vmw_vmci/vmci_guest.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/misc/vmw_vmci/vmci_guest.c b/drivers/misc/vmw_vmci/vmci_guest.c index aa61a687b3e2..6e072728c4e0 100644 --- a/drivers/misc/vmw_vmci/vmci_guest.c +++ b/drivers/misc/vmw_vmci/vmci_guest.c @@ -767,7 +767,7 @@ static int vmci_guest_probe_device(struct pci_dev *pdev, /* Check host capabilities. */ error = vmci_check_host_caps(pdev); if (error) - goto err_remove_bitmap; + goto err_remove_vmci_dev_g; /* Enable device. */ @@ -797,7 +797,7 @@ static int vmci_guest_probe_device(struct pci_dev *pdev, error = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSIX | PCI_IRQ_MSI | PCI_IRQ_LEGACY); if (error < 0) - goto err_remove_bitmap; + goto err_unsubscribe_event; } else { vmci_dev->exclusive_vectors = true; } @@ -873,13 +873,19 @@ static int vmci_guest_probe_device(struct pci_dev *pdev, err_disable_msi: pci_free_irq_vectors(pdev); +err_unsubscribe_event: vmci_err = vmci_event_unsubscribe(ctx_update_sub_id); if (vmci_err < VMCI_SUCCESS) dev_warn(&pdev->dev, "Failed to unsubscribe from event (type=%d) with subscriber (ID=0x%x): %d\n", VMCI_EVENT_CTX_ID_UPDATE, ctx_update_sub_id, vmci_err); -err_remove_bitmap: +err_remove_vmci_dev_g: + spin_lock_irq(&vmci_dev_spinlock); + vmci_pdev = NULL; + vmci_dev_g = NULL; + spin_unlock_irq(&vmci_dev_spinlock); + if (vmci_dev->notification_bitmap) { vmci_write_reg(vmci_dev, VMCI_CONTROL_RESET, VMCI_CONTROL_ADDR); dma_free_coherent(&pdev->dev, PAGE_SIZE, @@ -887,12 +893,6 @@ static int vmci_guest_probe_device(struct pci_dev *pdev, vmci_dev->notification_base); } -err_remove_vmci_dev_g: - spin_lock_irq(&vmci_dev_spinlock); - vmci_pdev = NULL; - vmci_dev_g = NULL; - spin_unlock_irq(&vmci_dev_spinlock); - err_free_data_buffers: vmci_free_dg_buffers(vmci_dev);