[PATCH v3 07/17] i3c: renesas: Do not attach devices if xfer failed
From: Claudiu Beznea
Date: Mon Jun 08 2026 - 16:20:59 EST
From: Claudiu Beznea <claudiu.beznea.uj@xxxxxxxxxxxxxx>
The controller may return an NRSPQP_ERROR_* error code while still
providing a valid cmd->rx_count. It has been observed that when the
transfer fails with NRSPQP_ERROR_ADDRESS_NACK, calling
i3c_master_add_i3c_dev_locked() may lead to crashes. Set newdevs to zero
if the transfer failed.
Fixes: e7218986319b ("i3c: renesas: Add suspend/resume support")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@xxxxxxxxxxxxxx>
---
Changes in v3:
- none
Changes in v2:
- none, this patch is new
drivers/i3c/master/renesas-i3c.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/i3c/master/renesas-i3c.c b/drivers/i3c/master/renesas-i3c.c
index c475d30a84c7..f96848022c45 100644
--- a/drivers/i3c/master/renesas-i3c.c
+++ b/drivers/i3c/master/renesas-i3c.c
@@ -780,10 +780,15 @@ static int renesas_i3c_daa(struct i3c_master_controller *m)
renesas_i3c_wait_xfer(i3c, xfer);
- newdevs = GENMASK(i3c->maxdevs - cmd->rx_count - 1, first_i3c_pos);
- /* Re-attach all the I3C devices on resume. */
- if (!i3c->resuming)
- newdevs &= ~olddevs;
+ /* Skip attaching if there are failures on the xfer. */
+ if (xfer->ret) {
+ newdevs = 0;
+ } else {
+ newdevs = GENMASK(i3c->maxdevs - cmd->rx_count - 1, first_i3c_pos);
+ /* Re-attach all the I3C devices on resume. */
+ if (!i3c->resuming)
+ newdevs &= ~olddevs;
+ }
for (pos = 0; pos < i3c->maxdevs; pos++) {
if (!(newdevs & BIT(pos)))
--
2.43.0