public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Daniel Hodges <git@danielhodges.dev>
To: Ian Abbott <abbotti@mev.co.uk>,
	H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Greg Kroah-Hartman <gregkh@suse.de>,
	linux-kernel@vger.kernel.org,
	Daniel Hodges <git@danielhodges.dev>,
	syzbot+72f94b474d6e50b71ffc@syzkaller.appspotmail.com
Subject: [PATCH] comedi: dt2815: return error when board not found during attach
Date: Sat,  7 Feb 2026 19:16:00 -0500	[thread overview]
Message-ID: <20260208001600.3447-1-git@danielhodges.dev> (raw)

dt2815_attach() silently succeeds even when the hardware initialization
loop fails to detect the board (status never becomes 4). This allows the
driver to attach to non-existent hardware at arbitrary I/O ports
provided via ioctl, which can cause a page fault when the driver
subsequently accesses those ports in QEMU/virtualized environments.

Fix this by returning -EIO when the initialization loop completes
without detecting the hardware, similar to what dt282x_initialize()
does. Change the success path from 'break' to 'return 0' so that the
function only returns success when hardware is actually detected.

Reported-by: syzbot+72f94b474d6e50b71ffc@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=72f94b474d6e50b71ffc
Fixes: d6a929b7608a ("Staging: comedi: add dt2815 driver")
Signed-off-by: Daniel Hodges <git@danielhodges.dev>
---
 drivers/comedi/drivers/dt2815.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/comedi/drivers/dt2815.c b/drivers/comedi/drivers/dt2815.c
index 03ba2fd18a21..d104ac0f015d 100644
--- a/drivers/comedi/drivers/dt2815.c
+++ b/drivers/comedi/drivers/dt2815.c
@@ -190,7 +190,7 @@ static int dt2815_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 			outb(program, dev->iobase + DT2815_DATA);
 			dev_dbg(dev->class_dev, "program: 0x%x (@t=%d)\n",
 				program, i);
-			break;
+			return 0;
 		} else if (status != 0x00) {
 			dev_dbg(dev->class_dev,
 				"unexpected status 0x%x (@t=%d)\n",
@@ -200,7 +200,8 @@ static int dt2815_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 		}
 	}
 
-	return 0;
+	dev_err(dev->class_dev, "board not found\n");
+	return -EIO;
 }
 
 static struct comedi_driver dt2815_driver = {
-- 
2.52.0


                 reply	other threads:[~2026-02-08  0:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260208001600.3447-1-git@danielhodges.dev \
    --to=git@danielhodges.dev \
    --cc=abbotti@mev.co.uk \
    --cc=gregkh@suse.de \
    --cc=hsweeten@visionengravers.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+72f94b474d6e50b71ffc@syzkaller.appspotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox