[PATCH 3/6] staging: comedi: drivers (core): don't BUG_ON because of faulty drivers

H Hartley Sweeten hsweeten at visionengravers.com
Fri Dec 21 16:51:21 UTC 2012


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 loading the
faulty driver but does not BUG the kernel.

Signed-off-by: H Hartley Sweeten <hsweeten at visionengravers.com>
Cc: Ian Abbott <abbobbi at mev.co.uk>
Cc: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
---
 drivers/staging/comedi/drivers.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
index 746b298..84e2cf61 100644
--- a/drivers/staging/comedi/drivers.c
+++ b/drivers/staging/comedi/drivers.c
@@ -176,8 +176,16 @@ static int postconfig_async_subdevice(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) {
-- 
1.8.0




More information about the devel mailing list