From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E9F43630AC; Sat, 12 Sep 2026 14:44:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789224298; cv=none; b=VHzp1nI/vEVv+6VYepJ9Qt/zJIZxcIVQhBHB/S0febVIqO73HsiE8jw3s1sa312Tz0IPWr6bDCOCWqpn9AvlRzN8kOr6V7i51vt/zsbtsKP2iWYbhAU0pPenvkDzP67HbPxQRc/3U5F3ejmV3gwVkKrsnbIJ/2yq7zZd+DqmAAU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789224298; c=relaxed/simple; bh=yYyIa7/lJRb4HNId/Y3YDI3MXXN97L3yDG/GTiNj+DY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g1ObdYBCTielzRkxKmGK6T2mO1Nw/lX4UxLFo9a8kcsOokDbgquaqJ+9Pq6Q2mHS9CXfPRrKzZi3pMhgUuL2J5Nc7xgDsslMyzLMktoUJkgIcklxhStpauMbC4iesJqsP5Ljr/XALYUatvqM9jrh3Y9RXcul7I24U9jqNpfIpe4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ehn8KoRb; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ehn8KoRb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F02301F000FF; Sat, 12 Sep 2026 14:44:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789224294; bh=N6F1AekQILWmYo3tQBldv/LDNPRjWFUaqPi/kjjII+4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ehn8KoRbn5/L4vuYFRHGfPzoxDuFoDVt+9prfG0LVMRTmIwvaEBJ6tCQZ6FpVgMSl Jk7dgomtW+JmliXY8JnBVDjI2fQGaldGxAM+rGih2DXTPKYOln6UgOkAiesagC9yU5 elw0d/kQRSWizyhjHn5b+0PQTJ/iFltaGeAXr/tA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, sashiko-bot@kernel.org, Adrian Hunter , Frank Li , Alexandre Belloni , Sasha Levin Subject: [PATCH 6.6 0965/1424] i3c: master: Fix device_register() error path Date: Sat, 12 Sep 2026 08:56:37 +0200 Message-ID: <20260912065628.923146990@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065607.279695368@linuxfoundation.org> References: <20260912065607.279695368@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Adrian Hunter [ Upstream commit 74be657d98a8d684c0475f3cbd450ef2a30ffc73 ] When device_register() fails in i3c_master_register_new_i3c_devs(), put_device() is called to drop the reference taken by device_register(). That drops the last reference, so the device's release callback i3c_device_release() runs and frees the i3c_device. Two problems follow from that: i3c_device_release() does WARN_ON(i3cdev->desc), so it warns because desc->dev->desc still points back at the descriptor. Clear it before calling put_device(). After put_device() frees the i3c_device, desc->dev is left pointing at freed memory, so clear desc->dev as well. That prevents, for example, i3c_master_unregister_i3c_devs() seeing desc->dev as non-NULL and dereferencing it. Reported-by: sashiko-bot@kernel.org Link: https://lore.kernel.org/linux-i3c/20260701203053.8F3971F000E9@smtp.kernel.org/ Fixes: cab63f6488761 ("i3c: Fix potential refcount leak in i3c_master_register_new_i3c_devs") Signed-off-by: Adrian Hunter Reviewed-by: Frank Li Link: https://patch.msgid.link/20260702183644.60827-1-adrian.hunter@intel.com Signed-off-by: Alexandre Belloni Signed-off-by: Sasha Levin --- drivers/i3c/master.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index a87be01e83ab1..330f87c65bff4 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -1648,7 +1648,9 @@ i3c_master_register_new_i3c_devs(struct i3c_master_controller *master) if (ret) { dev_err(&master->dev, "Failed to add I3C device (err = %d)\n", ret); + desc->dev->desc = NULL; put_device(&desc->dev->dev); + desc->dev = NULL; } } } -- 2.53.0