From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 8886B24DFF3; Tue, 29 Apr 2025 17:45:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745948736; cv=none; b=b33jsD+ruE1zQGp8eGK0m20VI/ywl/LPXmA4wk8VAnsXutDtrcCRE/OZdVV4qXcn4M8pgpPtKzf8DyUdAzDSBeMaqPQ21lPWeWs8OuYPYs96bqE7JsdxKFHcsx4l1VF4zMV9eZRsAPKVNSIbYq6WUQcR4xLFjm64hU+LZ6Q+qrU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745948736; c=relaxed/simple; bh=1dyTQkL2RGr94G/A83fwLKrIA3BUQ+KG/ngEDV8UzwE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=B7BSZzVvMsaLRMvUPUCiBjDmzssX9dtfj634z1EnqM3OuJYkXFTHACjo81I/X8E9iRXRVvi4jiWv1akGZcFqMq2SH6FcTvLL8tg5fZsuoweEk929VpkubTG1yeGrjGXBTFiqQRD4v0HKmJs6lFPl2hWOj5DC/FMSD2xzBmaIG0U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Fm8U0DN9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Fm8U0DN9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D6F2C4CEE3; Tue, 29 Apr 2025 17:45:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1745948736; bh=1dyTQkL2RGr94G/A83fwLKrIA3BUQ+KG/ngEDV8UzwE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fm8U0DN9cE9u5STt5Aj/L0hmKQqxFWhJO7LRaOVrEAOclNvf4WModjRfR9PTDnhPd h2dcfkoWAFHwXfxE0n+cwwhA3dmIQr+gqTEaL0bhrS7AOEI7wvXXfserD7+OWLMt3b fJahxB8E37thqrTDeFqwE0PKaByGQ0PUCAGEbezE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Manjunatha Venkatesh , Frank Li , Alexandre Belloni Subject: [PATCH 5.15 089/373] i3c: Add NULL pointer check in i3c_master_queue_ibi() Date: Tue, 29 Apr 2025 18:39:26 +0200 Message-ID: <20250429161126.823377957@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250429161123.119104857@linuxfoundation.org> References: <20250429161123.119104857@linuxfoundation.org> User-Agent: quilt/0.68 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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Manjunatha Venkatesh commit bd496a44f041da9ef3afe14d1d6193d460424e91 upstream. The I3C master driver may receive an IBI from a target device that has not been probed yet. In such cases, the master calls `i3c_master_queue_ibi()` to queue an IBI work task, leading to "Unable to handle kernel read from unreadable memory" and resulting in a kernel panic. Typical IBI handling flow: 1. The I3C master scans target devices and probes their respective drivers. 2. The target device driver calls `i3c_device_request_ibi()` to enable IBI and assigns `dev->ibi = ibi`. 3. The I3C master receives an IBI from the target device and calls `i3c_master_queue_ibi()` to queue the target device driver’s IBI handler task. However, since target device events are asynchronous to the I3C probe sequence, step 3 may occur before step 2, causing `dev->ibi` to be `NULL`, leading to a kernel panic. Add a NULL pointer check in `i3c_master_queue_ibi()` to prevent accessing an uninitialized `dev->ibi`, ensuring stability. Fixes: 3a379bbcea0af ("i3c: Add core I3C infrastructure") Cc: stable@vger.kernel.org Link: https://lore.kernel.org/lkml/Z9gjGYudiYyl3bSe@lizhi-Precision-Tower-5810/ Signed-off-by: Manjunatha Venkatesh Reviewed-by: Frank Li Link: https://lore.kernel.org/r/20250326123047.2797946-1-manjunatha.venkatesh@nxp.com Signed-off-by: Alexandre Belloni Signed-off-by: Greg Kroah-Hartman --- drivers/i3c/master.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -2240,6 +2240,9 @@ static void i3c_master_unregister_i3c_de */ void i3c_master_queue_ibi(struct i3c_dev_desc *dev, struct i3c_ibi_slot *slot) { + if (!dev->ibi || !slot) + return; + atomic_inc(&dev->ibi->pending_ibis); queue_work(dev->common.master->wq, &slot->work); }