summaryrefslogtreecommitdiff
path: root/drivers/staging/comedi/drivers.c
diff options
context:
space:
mode:
authorH Hartley Sweeten <hartleys@visionengravers.com>2012-06-12 18:57:45 (GMT)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-06-12 21:44:03 (GMT)
commit7f801c41714729f7741a042de839918be2bb56f0 (patch)
treed3d3f3d65a121e9d2c64b3177ea852f5914ea729 /drivers/staging/comedi/drivers.c
parent8b9ba6e5efc3213f384cda155861a4f7ae903365 (diff)
downloadlinux-fsl-qoriq-7f801c41714729f7741a042de839918be2bb56f0.tar.xz
staging: comedi: sanity check num_subdevices parameter in comedi_alloc_subdevices
It's possible for a couple of the comedi drivers to incorrectly call comedi_alloc_subdevices with num_subdevices = 0. Add a sanity check before doing the kcalloc. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbot@mev.co.uk> Cc: Frank Mori Hess <kmhess@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/comedi/drivers.c')
-rw-r--r--drivers/staging/comedi/drivers.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
index 979aa0e..61161ce 100644
--- a/drivers/staging/comedi/drivers.c
+++ b/drivers/staging/comedi/drivers.c
@@ -60,6 +60,8 @@ int comedi_alloc_subdevices(struct comedi_device *dev, int num_subdevices)
{
int i;
+ if (num_subdevices < 1)
+ return -EINVAL;
dev->n_subdevices = num_subdevices;
dev->subdevices =
kcalloc(num_subdevices, sizeof(struct comedi_subdevice),