git: 2abdb305bd0c - main - iichid(4): Do not send packets read in interrupt handler to hidbus

From: Vladimir Kondratyev <wulf_at_FreeBSD.org>
Date: Mon, 28 Apr 2025 21:40:07 UTC
The branch main has been updated by wulf:

URL: https://cgit.FreeBSD.org/src/commit/?id=2abdb305bd0c105226f6a71a8d3dc89698c9ef6b

commit 2abdb305bd0c105226f6a71a8d3dc89698c9ef6b
Author:     Vladimir Kondratyev <wulf@FreeBSD.org>
AuthorDate: 2025-04-28 21:39:28 +0000
Commit:     Vladimir Kondratyev <wulf@FreeBSD.org>
CommitDate: 2025-04-28 21:39:28 +0000

    iichid(4): Do not send packets read in interrupt handler to hidbus
    
    if no hidbus and hidbus clients were attached and opened by users.
    
    iichid(4) enables interrupts before hidbus is attached and sending
    packets to it at this time leads to panic at boot time.
    
    Fixes: daa098cc37b9 ("Wait for RESET command response while attaching")
    
    Tested by:      dch
    PR:             286045
    MFC with:       daa098cc37b9
---
 sys/dev/iicbus/iichid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/dev/iicbus/iichid.c b/sys/dev/iicbus/iichid.c
index b86858791a4d..9c0324a24685 100644
--- a/sys/dev/iicbus/iichid.c
+++ b/sys/dev/iicbus/iichid.c
@@ -630,7 +630,7 @@ iichid_intr(void *context)
 	error = iichid_cmd_read(sc, sc->intr_buf, sc->intr_bufsize, &actual);
 	THREAD_NO_SLEEPING();
 	if (error == 0) {
-		if (sc->power_on) {
+		if (sc->power_on && sc->open) {
 			if (actual != 0)
 				sc->intr_handler(sc->intr_ctx, sc->intr_buf,
 				    actual);