Drivers should not crash the kernel. This function is only called by comedi_device_detach_cleanup() and the s->minor will always be valid or the device wouldn't have attached in the first place.
Leave the checks for safety in accessing the comedi_subdevice_minor_table array but remove the BUG_ON() calls. Signed-off-by: H Hartley Sweeten <hswee...@visionengravers.com> Cc: Ian Abbott <abbo...@mev.co.uk> Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org> --- drivers/staging/comedi/comedi_fops.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index a49b385..dbca28f 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -2831,12 +2831,10 @@ void comedi_free_subdevice_minor(struct comedi_subdevice *s) if (!s) return; - if (s->minor < 0) + if (s->minor < COMEDI_NUM_BOARD_MINORS || + s->minor >= COMEDI_NUM_MINORS) return; - BUG_ON(s->minor >= COMEDI_NUM_MINORS); - BUG_ON(s->minor < COMEDI_NUM_BOARD_MINORS); - i = s->minor - COMEDI_NUM_BOARD_MINORS; mutex_lock(&comedi_subdevice_minor_table_lock); if (s == comedi_subdevice_minor_table[i]) -- 2.4.3 _______________________________________________ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel