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 4067127453; Tue, 29 Apr 2025 17:13:24 +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=1745946804; cv=none; b=rUQT+GOAwr7BoxrDHGKHqcX5q4cMn8/vqQMGEft67i/3QcjGx8pRNzSiePTSkqkJqPIXvOMMyKmyt6nKvCTcAcC7civBwdjutWb6qZ0ETY8cgkT6KzSmehAJa1hFwC9+zu6NvBJRlI+xPbA4cdRE4XxlYq1qdrG2ktTHs1I4bqA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745946804; c=relaxed/simple; bh=MJ5iiKWvpUmZrDJyLOaf66S/XGBgGr5YOC2ERE50U1Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Yrh+awmjwV695G5ebw6fpFhH3zgq6+AOjkEtZFXimDgQ5WBH5UVPxxZTKxlsxdxUxMgWhwUK4ZRFEyJrrcqoYRb2Tir+5NmrPOPwJxZrKDaaiJQjSPd6BletpN7l2E+gMqdjlvbwnJNnMaC5/0X90+Rc3CTw1A1Dw3fHh0nBhAI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=fIDL2NLm; 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="fIDL2NLm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BEBAFC4CEE3; Tue, 29 Apr 2025 17:13:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1745946804; bh=MJ5iiKWvpUmZrDJyLOaf66S/XGBgGr5YOC2ERE50U1Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fIDL2NLm/pzGr1/EJ2XJqEF+avKYpzi7xh6XrBo/AfSOgLcyaYImgFqnuHwjhqkZq oHwFFpiJd7LOChErwX3hVg2vM3GO/5Aa+thjUPH7aaIMk23GjtpPDg+hstgIMAWBCW Ah2lAIQ1IMmpVodVdYKDrjsSPNU4ZcAG+CC3bz/0= 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.10 075/286] i3c: Add NULL pointer check in i3c_master_queue_ibi() Date: Tue, 29 Apr 2025 18:39:39 +0200 Message-ID: <20250429161110.936982401@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250429161107.848008295@linuxfoundation.org> References: <20250429161107.848008295@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.10-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 @@ -2282,6 +2282,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); }