From nobody Sun Apr 19 12:15:44 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 5A14FC433EF for ; Fri, 1 Jul 2022 07:38:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235358AbiGAHiC (ORCPT ); Fri, 1 Jul 2022 03:38:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235222AbiGAHiA (ORCPT ); Fri, 1 Jul 2022 03:38:00 -0400 Received: from unicom145.biz-email.net (unicom145.biz-email.net [210.51.26.145]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 310536D576 for ; Fri, 1 Jul 2022 00:37:58 -0700 (PDT) Received: from ([60.208.111.195]) by unicom145.biz-email.net ((D)) with ASMTP (SSL) id VEM00054; Fri, 01 Jul 2022 15:37:54 +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:37:53 +0800 From: Bo Liu To: , , CC: , , , Bo Liu Subject: [PATCH] iommu/amd: Handle return of iommu_device_sysfs_add Date: Fri, 1 Jul 2022 02:20:08 -0400 Message-ID: <20220701062008.6988-1-liubo03@inspur.com> X-Mailer: git-send-email 2.18.2 MIME-Version: 1.0 X-Originating-IP: [10.200.104.97] tUid: 2022701153754142284bb54b59ca6fffe76b63419a9b2 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" As iommu_device_sysfs_add() can fail, we should check the return value. Signed-off-by: Bo Liu --- drivers/iommu/amd/init.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c index 3c82d9c5f1c0..a3c4fdd40f04 100644 --- a/drivers/iommu/amd/init.c +++ b/drivers/iommu/amd/init.c @@ -2058,8 +2058,11 @@ static int __init iommu_init_pci(struct amd_iommu *i= ommu) amd_iommu_erratum_746_workaround(iommu); amd_iommu_ats_write_check_workaround(iommu); =20 - iommu_device_sysfs_add(&iommu->iommu, &iommu->dev->dev, + ret =3D iommu_device_sysfs_add(&iommu->iommu, &iommu->dev->dev, amd_iommu_groups, "ivhd%d", iommu->index); + if (ret) + return ret; + iommu_device_register(&iommu->iommu, &amd_iommu_ops, NULL); =20 return pci_enable_device(iommu->dev); --=20 2.27.0