summaryrefslogtreecommitdiff
path: root/drivers/staging/comedi/drivers.c
diff options
context:
space:
mode:
authorH Hartley Sweeten <hartleys@visionengravers.com>2012-06-12 18:58:27 (GMT)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-06-12 21:44:03 (GMT)
commitfba1d0faf726b442ab8771d5e9fbaf5f5a4c624c (patch)
treea0725fb72c1cb5091be27d05a338eae2bed6fe78 /drivers/staging/comedi/drivers.c
parent7f801c41714729f7741a042de839918be2bb56f0 (diff)
downloadlinux-fsl-qoriq-fba1d0faf726b442ab8771d5e9fbaf5f5a4c624c.tar.xz
staging: comedi: only set dev->n_subdevices when kcalloc succeedes
It's possible for the kcalloc in comedi_alloc_subdevices to fail. Only set the dev->n_subdevices variable if the allocation is successful. Since the core sets dev->n_subdevices, remove all the places in the drivers where this variable was getting set. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbott@mev.co.uk> Cc: Frank Mori Hess <fmhess@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, 1 insertions, 1 deletions
diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
index 61161ce..ecad228 100644
--- a/drivers/staging/comedi/drivers.c
+++ b/drivers/staging/comedi/drivers.c
@@ -62,12 +62,12 @@ int comedi_alloc_subdevices(struct comedi_device *dev, int num_subdevices)
if (num_subdevices < 1)
return -EINVAL;
- dev->n_subdevices = num_subdevices;
dev->subdevices =
kcalloc(num_subdevices, sizeof(struct comedi_subdevice),
GFP_KERNEL);
if (!dev->subdevices)
return -ENOMEM;
+ dev->n_subdevices = num_subdevices;
for (i = 0; i < num_subdevices; ++i) {
dev->subdevices[i].device = dev;
dev->subdevices[i].async_dma_dir = DMA_NONE;