From: Prabhakar Pujeri <prabhakar.pujeri@gmail.com>
To: abbotti@mev.co.uk, hsweeten@visionengravers.com
Cc: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
Super User <root@localhost.localdomain>,
syzbot+ab8008c24e84adee93ff@syzkaller.appspotmail.com,
Prabhakar Pujeri <prabhakar.pujeri@gmail.com>
Subject: [PATCH] [PATCH] comedi: check for NULL get_valid_routes function pointer
Date: Sun, 20 Jul 2025 02:33:50 -0500 [thread overview]
Message-ID: <20250720073350.22251-1-prabhakar.pujeri@gmail.com> (raw)
From: Super User <root@localhost.localdomain>
The function get_valid_routes() calls the low-level driver's
dev->get_valid_routes() callback directly without checking if it is
set. If this function pointer is NULL, the kernel crashes with a
NULL instruction pointer dereference.
This patch adds a check to ensure the callback is present before
calling it, and returns -EINVAL if it is missing.
This prevents a kernel crash when user space invokes an ioctl that
results in get_valid_routes() being called on drivers that do not
implement the callback.
Reported-by: syzbot+ab8008c24e84adee93ff@syzkaller.appspotmail.com
Signed-off-by: Prabhakar Pujeri <prabhakar.pujeri@gmail.com>
---
drivers/comedi/comedi_fops.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/comedi/comedi_fops.c b/drivers/comedi/comedi_fops.c
index 3383a7ce27ff..2b8cb280287b 100644
--- a/drivers/comedi/comedi_fops.c
+++ b/drivers/comedi/comedi_fops.c
@@ -1302,6 +1302,11 @@ static int check_insn_device_config_length(struct comedi_insn *insn,
static int get_valid_routes(struct comedi_device *dev, unsigned int *data)
{
lockdep_assert_held(&dev->mutex);
+ if (!dev->get_valid_routes) {
+ dev_warn(dev->class_dev ?: dev->hw_dev,
+ "get_valid_routes() not implemented\n");
+ return -EINVAL;
+ }
data[1] = dev->get_valid_routes(dev, data[1], data + 2);
return 0;
}
--
2.50.1
next reply other threads:[~2025-07-20 7:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-20 7:33 Prabhakar Pujeri [this message]
2025-07-20 8:35 ` Greg KH
2025-07-20 8:40 ` Ian Abbott
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=20250720073350.22251-1-prabhakar.pujeri@gmail.com \
--to=prabhakar.pujeri@gmail.com \
--cc=abbotti@mev.co.uk \
--cc=gregkh@linuxfoundation.org \
--cc=hsweeten@visionengravers.com \
--cc=linux-kernel@vger.kernel.org \
--cc=root@localhost.localdomain \
--cc=syzbot+ab8008c24e84adee93ff@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
all inboxes | Powered by JetHome®