From nobody Sun Apr 19 12:15:43 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 309D0C43334 for ; Fri, 1 Jul 2022 07:03:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234519AbiGAHD4 (ORCPT ); Fri, 1 Jul 2022 03:03:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbiGAHDw (ORCPT ); Fri, 1 Jul 2022 03:03:52 -0400 Received: from unicom146.biz-email.net (unicom146.biz-email.net [210.51.26.146]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EB89564E5 for ; Fri, 1 Jul 2022 00:03:48 -0700 (PDT) Received: from ([60.208.111.195]) by unicom146.biz-email.net ((D)) with ASMTP (SSL) id VEE00141; Fri, 01 Jul 2022 15:03:41 +0800 Received: from localhost.localdomain (10.200.104.97) by jtjnmail201607.home.langchao.com (10.100.2.7) with Microsoft SMTP Server id 15.1.2507.9; Fri, 1 Jul 2022 15:03:44 +0800 From: Bo Liu To: , , CC: , , , , Bo Liu Subject: [PATCH] iommu/virtio: Handle return of iommu_device_register Date: Fri, 1 Jul 2022 01:43:04 -0400 Message-ID: <20220701054304.6434-1-liubo03@inspur.com> X-Mailer: git-send-email 2.18.2 MIME-Version: 1.0 X-Originating-IP: [10.200.104.97] tUid: 20227011503418d5d708f5b31f05e32cd5086aa14c86f X-Abuse-Reports-To: service@corp-email.com Abuse-Reports-To: service@corp-email.com X-Complaints-To: service@corp-email.com X-Report-Abuse-To: service@corp-email.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" iommu_device_register returns an error code and, although it currently never fails, we should check its return value anyway. Signed-off-by: Bo Liu --- drivers/iommu/virtio-iommu.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c index 25be4b822aa0..12e7d8364560 100644 --- a/drivers/iommu/virtio-iommu.c +++ b/drivers/iommu/virtio-iommu.c @@ -1144,7 +1144,9 @@ static int viommu_probe(struct virtio_device *vdev) if (ret) goto err_free_vqs; =20 - iommu_device_register(&viommu->iommu, &viommu_ops, parent_dev); + ret =3D iommu_device_register(&viommu->iommu, &viommu_ops, parent_dev); + if (ret) + goto err_remove_sysfs; =20 #ifdef CONFIG_PCI if (pci_bus_type.iommu_ops !=3D &viommu_ops) { @@ -1175,8 +1177,9 @@ static int viommu_probe(struct virtio_device *vdev) return 0; =20 err_unregister: - iommu_device_sysfs_remove(&viommu->iommu); iommu_device_unregister(&viommu->iommu); +err_remove_sysfs: + iommu_device_sysfs_remove(&viommu->iommu); err_free_vqs: vdev->config->del_vqs(vdev); =20 --=20 2.27.0