From nobody Mon Jun 29 11:18:24 2026 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 76656C433F5 for ; Thu, 10 Feb 2022 22:27:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344819AbiBJW1W (ORCPT ); Thu, 10 Feb 2022 17:27:22 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344939AbiBJW1T (ORCPT ); Thu, 10 Feb 2022 17:27:19 -0500 Received: from smtp.smtpout.orange.fr (smtp03.smtpout.orange.fr [80.12.242.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90E8F262B for ; Thu, 10 Feb 2022 14:27:18 -0800 (PST) Received: from pop-os.home ([90.126.236.122]) by smtp.orange.fr with ESMTPA id IHuGnjGRR9r2MIHuGnUs0Z; Thu, 10 Feb 2022 23:27:17 +0100 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Thu, 10 Feb 2022 23:27:17 +0100 X-ME-IP: 90.126.236.122 From: Christophe JAILLET To: jhansen@vmware.com, vdasa@vmware.com, arnd@arndb.de, gregkh@linuxfoundation.org, acking@vmware.com, dtor@vmware.com Cc: pv-drivers@vmware.com, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH 1/3] VMCI: Fix the description of vmci_check_host_caps() Date: Thu, 10 Feb 2022 23:27:15 +0100 Message-Id: <7f7ad8c171566f6f8716c3451b9ddc2e83fe003f.1644531317.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" vmci_check_host_caps() doesn't return a bool but an int. Fix the description accordingly. Fixes: 782f24453536 ("VMCI: fix error handling path when registering guest= driver") Signed-off-by: Christophe JAILLET Acked-by: Vishnu Dasa --- drivers/misc/vmw_vmci/vmci_guest.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/misc/vmw_vmci/vmci_guest.c b/drivers/misc/vmw_vmci/vmc= i_guest.c index aa61a687b3e2..1a1858742f75 100644 --- a/drivers/misc/vmw_vmci/vmci_guest.c +++ b/drivers/misc/vmw_vmci/vmci_guest.c @@ -253,9 +253,9 @@ static void vmci_guest_cid_update(u32 sub_id, =20 /* * Verify that the host supports the hypercalls we need. If it does not, - * try to find fallback hypercalls and use those instead. Returns - * true if required hypercalls (or fallback hypercalls) are - * supported by the host, false otherwise. + * try to find fallback hypercalls and use those instead. Returns 0 if + * required hypercalls (or fallback hypercalls) are supported by the host, + * an error code otherwise. */ static int vmci_check_host_caps(struct pci_dev *pdev) { --=20 2.32.0 From nobody Mon Jun 29 11:18:24 2026 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 05D95C433EF for ; Thu, 10 Feb 2022 22:27:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344965AbiBJW1a (ORCPT ); Thu, 10 Feb 2022 17:27:30 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:52158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344943AbiBJW13 (ORCPT ); Thu, 10 Feb 2022 17:27:29 -0500 Received: from smtp.smtpout.orange.fr (smtp03.smtpout.orange.fr [80.12.242.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EE025589 for ; Thu, 10 Feb 2022 14:27:28 -0800 (PST) Received: from pop-os.home ([90.126.236.122]) by smtp.orange.fr with ESMTPA id IHuQnjGUw9r2MIHuQnUs1y; Thu, 10 Feb 2022 23:27:27 +0100 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Thu, 10 Feb 2022 23:27:27 +0100 X-ME-IP: 90.126.236.122 From: Christophe JAILLET To: jhansen@vmware.com, vdasa@vmware.com, arnd@arndb.de, gregkh@linuxfoundation.org, acking@vmware.com, dtor@vmware.com Cc: pv-drivers@vmware.com, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH 2/3] VMCI: No need to clear memory after a dma_alloc_coherent() call Date: Thu, 10 Feb 2022 23:27:25 +0100 Message-Id: <232d7bb2eace0d4dc2228134c6a424472412adfa.1644531317.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" dma_alloc_coherent() already clear the allocated memory, there is no need to explicitly call memset(). This saves a few cycles and a few lines of code. Signed-off-by: Christophe JAILLET Acked-by: Vishnu Dasa --- drivers/misc/vmw_vmci/vmci_guest.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/misc/vmw_vmci/vmci_guest.c b/drivers/misc/vmw_vmci/vmc= i_guest.c index 1a1858742f75..02d4722d8474 100644 --- a/drivers/misc/vmw_vmci/vmci_guest.c +++ b/drivers/misc/vmw_vmci/vmci_guest.c @@ -706,13 +706,11 @@ static int vmci_guest_probe_device(struct pci_dev *pd= ev, vmci_dev->notification_bitmap =3D dma_alloc_coherent( &pdev->dev, PAGE_SIZE, &vmci_dev->notification_base, GFP_KERNEL); - if (!vmci_dev->notification_bitmap) { + if (!vmci_dev->notification_bitmap) dev_warn(&pdev->dev, "Unable to allocate notification bitmap\n"); - } else { - memset(vmci_dev->notification_bitmap, 0, PAGE_SIZE); + else caps_in_use |=3D VMCI_CAPS_NOTIFICATIONS; - } } =20 if (mmio_base !=3D NULL) { --=20 2.32.0 From nobody Mon Jun 29 11:18:24 2026 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 13A2EC433FE for ; Thu, 10 Feb 2022 22:27:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344977AbiBJW1j (ORCPT ); Thu, 10 Feb 2022 17:27:39 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:52296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344908AbiBJW1h (ORCPT ); Thu, 10 Feb 2022 17:27:37 -0500 Received: from smtp.smtpout.orange.fr (smtp03.smtpout.orange.fr [80.12.242.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38EAB262B for ; Thu, 10 Feb 2022 14:27:37 -0800 (PST) Received: from pop-os.home ([90.126.236.122]) by smtp.orange.fr with ESMTPA id IHuZnjGYF9r2MIHuZnUs2h; Thu, 10 Feb 2022 23:27:35 +0100 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Thu, 10 Feb 2022 23:27:35 +0100 X-ME-IP: 90.126.236.122 From: Christophe JAILLET To: jhansen@vmware.com, vdasa@vmware.com, arnd@arndb.de, gregkh@linuxfoundation.org, acking@vmware.com, dtor@vmware.com Cc: pv-drivers@vmware.com, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH 3/3] VMCI: Fix some error handling paths in vmci_guest_probe_device() Date: Thu, 10 Feb 2022 23:27:34 +0100 Message-Id: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Christophe JAILLET Acked-by: Vishnu Dasa --- Review with GREAT care. This patch is a recent rebase of an old patch that has never been submitted. This function is huge and modifying its error handling path is error prone (at least for me). The patch is compile-tested only. --- 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/vmc= i_guest.c index 02d4722d8474..2e8ad36895ae 100644 --- a/drivers/misc/vmw_vmci/vmci_guest.c +++ b/drivers/misc/vmw_vmci/vmci_guest.c @@ -765,7 +765,7 @@ static int vmci_guest_probe_device(struct pci_dev *pdev, /* Check host capabilities. */ error =3D vmci_check_host_caps(pdev); if (error) - goto err_remove_bitmap; + goto err_remove_vmci_dev_g; =20 /* Enable device. */ =20 @@ -795,7 +795,7 @@ static int vmci_guest_probe_device(struct pci_dev *pdev, error =3D 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_unsubscrive_event; } else { vmci_dev->exclusive_vectors =3D true; } @@ -871,13 +871,19 @@ static int vmci_guest_probe_device(struct pci_dev *pd= ev, err_disable_msi: pci_free_irq_vectors(pdev); =20 +err_unsubscrive_event: vmci_err =3D vmci_event_unsubscribe(ctx_update_sub_id); if (vmci_err < VMCI_SUCCESS) dev_warn(&pdev->dev, "Failed to unsubscribe from event (type=3D%d) with subscriber (ID=3D0x= %x): %d\n", VMCI_EVENT_CTX_ID_UPDATE, ctx_update_sub_id, vmci_err); =20 -err_remove_bitmap: +err_remove_vmci_dev_g: + spin_lock_irq(&vmci_dev_spinlock); + vmci_pdev =3D NULL; + vmci_dev_g =3D 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, @@ -885,12 +891,6 @@ static int vmci_guest_probe_device(struct pci_dev *pde= v, vmci_dev->notification_base); } =20 -err_remove_vmci_dev_g: - spin_lock_irq(&vmci_dev_spinlock); - vmci_pdev =3D NULL; - vmci_dev_g =3D NULL; - spin_unlock_irq(&vmci_dev_spinlock); - err_free_data_buffers: vmci_free_dg_buffers(vmci_dev); =20 --=20 2.32.0