Skip to content

Commit

Permalink
staging: comedi: drivers (core): don't BUG_ON due to faulty drivers
Browse files Browse the repository at this point in the history
The postconfig for drivers that support async commands currently can
BUG_ON if the subdevice was improperly configured by the driver.

Change the BUG_ON so that a dev_warn() is output and the postconfig
returns -EINVAL. This will prevent the comedi core from attaching to
the faulty driver but does not BUG the kernel.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Jan 21, 2013
1 parent 40f58a6 commit 57b71c3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions drivers/staging/comedi/drivers.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,16 @@ static int __comedi_device_postconfig_async(struct comedi_device *dev,
unsigned int buf_size;
int ret;

BUG_ON((s->subdev_flags & (SDF_CMD_READ | SDF_CMD_WRITE)) == 0);
BUG_ON(!s->do_cmdtest);
if ((s->subdev_flags & (SDF_CMD_READ | SDF_CMD_WRITE)) == 0) {
dev_warn(dev->class_dev,
"async subdevices must support SDF_CMD_READ or SDF_CMD_WRITE\n");
return -EINVAL;
}
if (!s->do_cmdtest) {
dev_warn(dev->class_dev,
"async subdevices must have a do_cmdtest() function\n");
return -EINVAL;
}

async = kzalloc(sizeof(*async), GFP_KERNEL);
if (!async) {
Expand Down

0 comments on commit 57b71c3

Please sign in to comment.