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 BC19E435EF2; Fri, 7 Aug 2026 15:45:58 +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=1786117559; cv=none; b=eBkL0+8rGe1YkqOsMLBUbL9E7/BJ4y9d0dZrVlx4rx5npgHm0H1QN6OFLFtsYmDw7l0VHjbhu+X5q8W0uPpF/vD5PTzGCTGeg0GorDorAcB+AE6lQKBylQZThSa/h/LMaJai66cVE5rCI/ab+el7z9/5/xiItc0cWDyc3J6dceU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786117559; c=relaxed/simple; bh=DnansIwvoCHsj/0g0A53NE9QI2n2T5cU6zSmK3/vH38=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YHSfvnkxtTN0iR+6Yp84Cip5K9Lh+3yICa0U9U7zAU38eb6axujofk1PAPs5/QDZ9pmaYvTcyT3UIcmp65i8FNw916FUBSszvThu00vJ32l+w+2OZznEtOrXEJw9K4l+rXkyl7ln9VEi5GsxseyyxmUvMXQMpdAeliFdGBMkfzA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=G2TYfhSQ; 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="G2TYfhSQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E8351F000E9; Fri, 7 Aug 2026 15:45:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1786117558; bh=36DW28HZxp7dKb4nIENMJIHg28omnY45h6jPAmqZtik=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=G2TYfhSQ92CcOxMde3qbY2Tg31yEwpKPNZyBtkexfsoONHIcxiMVdWbIVoiDZ2cP2 yUwMXnUbsR0rBAodLGvP5dpF/rxpurqx+XhJUzNt8/ENXImGGBmbGCmdPn4QkAVvSj 9cKr/rQevH6T60pUNR9NsAeuaiEpLRCdigIZmqAQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Liem , Carlos Song , Frank Li , Andi Shyti Subject: [PATCH 7.1 362/438] i2c: imx: Cancel hrtimer before clearing slave pointer Date: Fri, 7 Aug 2026 16:39:18 +0200 Message-ID: <20260807143435.691539155@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260807143428.008222056@linuxfoundation.org> References: <20260807143428.008222056@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 7.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Liem commit 6ac7702b6cc2b94aaed9ef2d95bfbefcdc90061f upstream. In i2c_imx_unreg_slave(), the slave pointer is set to NULL after disabling interrupts. However, a pending interrupt might already have started the hrtimer (i2c_imx_slave_timeout) before the pointer was cleared. If the hrtimer fires after i2c_imx->slave is set to NULL, the timer callback i2c_imx_slave_finish_op() will call i2c_imx_slave_event() with a NULL slave pointer, which results in a use-after-free / NULL pointer dereference. Fix by canceling the hrtimer and waiting for it to complete after disabling interrupts, before clearing the slave pointer. Fixes: f7414cd6923f ("i2c: imx: support slave mode for imx I2C driver") Signed-off-by: Liem Cc: # v5.11+ Acked-by: Carlos Song Reviewed-by: Frank Li Signed-off-by: Andi Shyti Link: https://lore.kernel.org/r/20260629023829.152651-3-liem16213@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/busses/i2c-imx.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -960,6 +960,7 @@ static int i2c_imx_unreg_slave(struct i2 i2c_imx_reset_regs(i2c_imx); + hrtimer_cancel(&i2c_imx->slave_timer); i2c_imx->slave = NULL; /* Suspend */