Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7f801c41 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman
Browse files

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: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbot@mev.co.uk>
Cc: Frank Mori Hess <kmhess@users.sourceforge.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8b9ba6e5
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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),