mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 3/8] staging: comedi: sanity check num_subdevices parameter in comedi_alloc_subdevices
@ 2012-06-12 18:57 H Hartley Sweeten
  0 siblings, 0 replies; only message in thread
From: H Hartley Sweeten @ 2012-06-12 18:57 UTC (permalink / raw)
  To: Linux Kernel; +Cc: devel, abbotti, fmhess, gregkh

>From 952298d9ff21bc8fba3ece36a634a7abad89d912 Mon Sep 17 00:00:00 2001
From: H Hartley Sweeten <hsweeten@visionengravers.com>
Date: Tue, 12 Jun 2012 09:53:02 -0700
Subject: [PATCH 3/8] 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>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/staging/comedi/drivers.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
index 87a87dd..4d5da37 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),
-- 
1.7.7


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-06-12 18:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-12 18:57 [PATCH 3/8] staging: comedi: sanity check num_subdevices parameter in comedi_alloc_subdevices H Hartley Sweeten

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®