From patchwork Tue Aug 13 15:15:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13762215 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6E4A2C52D7C for ; Tue, 13 Aug 2024 15:16:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To:In-Reply-To: References:Message-Id:Subject:Date:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=nHDAebsBdi9l/u65m5Vc1bUf1p0EyuwJIqW815LUlQU=; b=3ESpIsqjKfcth66KTMTF4/cKGd ArlE4b/i3piDAQFEL33eLvNTEMj0TwaDYGeejqJRMsAyfqfbcTNH2R2PIDNWJuXk4a+mbpIowO7NW F2F0ZjjVEgpbvcs0/GUMd66ND+6VTq7nDkqD7LjtqIIL8tFKHIZjOSWEc5zU6biq9zWkgsQa1Z18N G4/d9Rc5E4phfU3cppjZ8YJam1kdsAS3h6MFHamqv9ZgOHlScuoq31O3sgS/38XoeOGG4soRHaVJo rrErCKmjiz0AFmtRx5ourYaxBLbTu4qBuEx68sHfOXvuQaNl1SdYi6qM26zBFXzNECSsj7eQNU3ky 9FExKIjA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdtFn-00000004Ay1-0IMV; Tue, 13 Aug 2024 15:16:07 +0000 Received: from mail-northeuropeazlp170130004.outbound.protection.outlook.com ([2a01:111:f403:c200::4] helo=DUZPR83CU001.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdtFj-00000004Awj-49th for linux-i3c@lists.infradead.org; Tue, 13 Aug 2024 15:16:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PnM/YKQs+qbWLr92Ql4O/2Qh00vzLSgYqBSRDdJUWObNOd7SpPr189BsyPk7iikZzyrdrFzDHTmVqdPYzNmGMh9zjV+cFkkIywKTEH6l4ek5S8ZZbWB8hSzkQ4aTbbgWt/6dRvA173uETR/pmwmQrf9rWTFARuyJBcVWmH5fEjKYDwU8kyA2zYQ3dMZ02PSMureaJMyh0mfyR1SevWUIu5nsakI1dFg+dfo0WLGcQBmcDdXySgTiw4lI/zTSNyZAoCRvJ+RmZeXjsaJhxB0tvFj7GP1fKx4Gc87Aa/tIXrwlvYHhV8wF++0zAQ+AKxCYBrD2+mdc9ZtLBcEPLh4peg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2/SVwfWRORhLiOwxpskuAqNJQ7ey0W3ly62qeO1Waoo=; b=Hwh7rQ9vWMcG80LS7RxBNyoHSFnXs0Otb7EXj0/TxPI3KmYAgExmmWMaGtF5yuKRDLJh/2rzLsIcjo/jG2NNM3doVofjBDcQY3aUNPczshoaiGvx/liRSsn+LYx9a8f0R1R4outf78Aw9inWxnVNgsthn8Qw3uc6QOGbhRQxlEI3VDnjP7KqRcObnfAQGRYfrvC7uPw5ln4zpbD9Kf95MoyNiIBKua1gxubXSk4K1SmqhHjEnICQI4lNsDbqnRewuZiJ2UZsie6G66qZtoSDgneMn85Z6ByozAJ3mKOehgoW2s+R4s2E7KX4GQWsm+G+p/hgFDY9eaPHA9ogWMwvxg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2/SVwfWRORhLiOwxpskuAqNJQ7ey0W3ly62qeO1Waoo=; b=c27DUjVg0P/IAGIIybfGOVnxaUT2PVYml5WPp0CQEnEvhiR9DpzQ9yzjS/QrR3devDxgajYH1AuOl88JtQ6JdQkAOdq3vzjX3TQbs+B+sfs3llS4Ogxsj6q4GHsT/5Hebr55UiubFp9vPsl+lefF4vr5OMAC0sbMRCmQXyOkE/BN1s/u3J5Br+aKfGszbDmvs4qnpxxGHX157i7TjkgSQJ+f9X+n5OXTDg0LbxNrabZTLrPHddO1/2NArBc6V8BfwpvMRP3AmmjPTKc4MZB545XERyvYI6Gl3ydUR3sMGDCsoTZYr1K9EKtmo3k0ckfhhTCCNuPKsjQPusB0zxMcmQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by DU4PR04MB10623.eurprd04.prod.outlook.com (2603:10a6:10:580::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.20; Tue, 13 Aug 2024 15:16:01 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%3]) with mapi id 15.20.7849.019; Tue, 13 Aug 2024 15:15:56 +0000 From: Frank Li Date: Tue, 13 Aug 2024 11:15:09 -0400 Subject: [PATCH v2 11/11] i3c: master: svc: fix possible assignment of the same address to two devices Message-Id: <20240813-i3c_fix-v2-11-68fe4a050188@nxp.com> References: <20240813-i3c_fix-v2-0-68fe4a050188@nxp.com> In-Reply-To: <20240813-i3c_fix-v2-0-68fe4a050188@nxp.com> To: Alexandre Belloni , Boris Brezillon , Parshuram Thombare , Greg Kroah-Hartman , Boris Brezillon , Arnd Bergmann , Miquel Raynal , Conor Culhane Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Frank Li , stable@kernel.org X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1723562115; l=1988; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=DaLGN7qQFvP6oGFtxS4SP64nZLiI2N6XmjBeOGjaOcQ=; b=GmVe6uM9oxyEhl6ZteKP2TVSycfDEG5HUkd65JC7G2Zy73mA4c1KYOodtFIOdzdceRSsCCj9B cvpTEUv0I3nDC2sIgB+dEyGHHxGqyl9+wrJBOIc8D0tiD9/leFhTr4+ X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR05CA0125.namprd05.prod.outlook.com (2603:10b6:a03:33d::10) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DU4PR04MB10623:EE_ X-MS-Office365-Filtering-Correlation-Id: 82908c0c-227a-4542-cfe7-08dcbbaad47f X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|52116014|7416014|376014|38350700014; X-Micros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pj+2FxCESFe8u1NvS0LSBPIauaT3zqmbNRyCPo7LGsh5bJTIIKlTVVIVba?= =?utf-8?q?xUPtLq/ayZb/KNzkgOkXUijk3DznDNDtwxRv4owJk0pBqu9FQmUe5HsQ61fH8oy+I?= =?utf-8?q?loX4OHIFz8GhR0aOaO25zeaTM/S0KpNyVB5q4/0i2Dymms80NDS41IrULs5UtLAk3?= =?utf-8?q?ONKbwi1Ah94sANmrAaSHExlyhqg24cuhSlFShiZYFrJNMhLZIPLNhsvRLiDDhU8xv?= =?utf-8?q?Ha6X20j3yM0E0cTBjXRvhmimNV9d3PbtT+ThLWCGYUcunLO6zLIkmovQ1PVfVTprQ?= =?utf-8?q?Ly4CrVAEfPusT5mjRwb7PMOeeYYUDpFN4gLqDkQknXsFFRmB/fqYJQc3K37p/ZdCn?= =?utf-8?q?af/xkPvzLpR3T+ocV8sSrzk1dciyHJjTDwQ9K3xMxOBZ+tSITu1jt6NGN0lpk4o6M?= =?utf-8?q?qYjWAf5xOSGeVXR8D+RqtUbKTiQk4mQUGJOtyZ/wEpZIhbrKy8tsRs7C3K1TqrKNV?= =?utf-8?q?CLxflncTDFcRNx6/dNc1VnQkSe+yKQ+McA=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(52116014)(7416014)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?4/oTq6gElOxNhdkxIrkqcICjQYcN?= =?utf-8?q?aAjIw1B2XYjvd27lnRWchJkkoQdPNJj7lqEOTwtccZkiikY+w9vA5nqjYkvcMe0lK?= =?utf-8?q?e/PzoTNtv3ScrovMgkV5vJ/3SDWrhrJ+FvhsAndtbIN6h95FlmO03AfLemm+9O58j?= =?ut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jzx?= =?utf-8?q?gKq5C1CJvx/0tC4q+AMveoetlJnD+tTuHQZhopQB7YimSAMg9jWBrhwzm7qaeyt+7?= =?utf-8?q?7n0qHHS6gNwdgxVVgHQ5AlkA2BBBHIXPxGiyJ/UzNGMYT+zdDirk0DyAorE0hNeZB?= =?utf-8?q?6gt40OJDU4A2L2v9WPknOl+eLELEB8WxaOvOE7YDyedkIz+4Dp8Qf+j0upXrki98V?= =?utf-8?q?0yC6/9UdDJ1T66DhZt4FWrQOJmfxW3IJKcgiEUuD9VCHdFPMmeORiHGZ9b3W0SOkh?= =?utf-8?q?X0mNxcVhLxQfsp++KOZisbrqK/SV9PQN3Cow3WuTrnCNmt30OybwShx/gUT0U0i6N?= =?utf-8?q?EkNtwLK2uKPEs36lzxd1GNobnNcIEaQW7V8vQurkJaEBHUo4QJS+FyhcivZNRZtVy?= =?utf-8?q?TmLJWCcaytmuLlxGLURMZq00lKCYe8wb/FuCNd3gmHthvPTWPuIDQ7+TmAAXui0bG?= =?utf-8?q?620lqRguZogCOBzjm0xR1BIF5ZswYYVPcbh5fFMEv+bVHbn11Yb0EgP8=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 82908c0c-227a-4542-cfe7-08dcbbaad47f X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2024 15:15:56.4539 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jMWJi6sxoONkt/rwkcAjeCKoZX/VOsGfbCnfL5veBpGyM3Oz5a3LokRup3dcHTfKcn/PjcguRmXtq6wZ5Donaw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU4PR04MB10623 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240813_081604_071616_30DF9992 X-CRM114-Status: GOOD ( 14.09 ) X-BeenThere: linux-i3c@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=archiver.kernel.org@lists.infradead.org svc_i3c_master_do_daa() { ... for (i = 0; i < dev_nb; i++) { ret = i3c_master_add_i3c_dev_locked(m, addrs[i]); if (ret) goto rpm_out; } } If two devices (A and B) are detected in DAA and address 0xa is assigned to device A and 0xb to device B, a failure in i3c_master_add_i3c_dev_locked() for device A (addr: 0xa) could prevent device B (addr: 0xb) from being registered on the bus. The I3C stack might still consider 0xb a free address. If a subsequent Hotjoin occurs, 0xb might be assigned to Device A, causing both devices A and B to use the same address 0xb, violating the I3C specification. The return value for i3c_master_add_i3c_dev_locked() should not be checked because subsequent steps will scan the entire I3C bus, independent of whether i3c_master_add_i3c_dev_locked() returns success. If device A registration fails, there is still a chance to register device B. i3c_master_add_i3c_dev_locked() can reset DAA if a failure occurs while retrieving device information. Cc: stable@kernel.org Fixes: 317bacf960a4 ("i3c: master: add enable(disable) hot join in sys entry") Signed-off-by: Frank Li --- drivers/i3c/master/svc-i3c-master.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index 0de95f406c95b..f47e5f4af68c9 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -1041,11 +1041,8 @@ static int svc_i3c_master_do_daa(struct i3c_master_controller *m) goto rpm_out; /* Register all devices who participated to the core */ - for (i = 0; i < dev_nb; i++) { - ret = i3c_master_add_i3c_dev_locked(m, addrs[i]); - if (ret) - goto rpm_out; - } + for (i = 0; i < dev_nb; i++) + i3c_master_add_i3c_dev_locked(m, addrs[i]); /* Configure IBI auto-rules */ ret = svc_i3c_update_ibirules(master);