Commit 04226e40 authored by Geliang Tang's avatar Geliang Tang Committed by Greg Kroah-Hartman

staging: comedi: use kmalloc_array instead of kmalloc

Use kmalloc_array instead of kmalloc to allocate memory for an array.
Signed-off-by: default avatarGeliang Tang <geliangtang@163.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 6e411751
......@@ -1022,14 +1022,17 @@ pci224_auto_attach(struct comedi_device *dev, unsigned long context_model)
irq = pci_dev->irq;
/* Allocate buffer to hold values for AO channel scan. */
devpriv->ao_scan_vals = kmalloc(sizeof(devpriv->ao_scan_vals[0]) *
board->ao_chans, GFP_KERNEL);
devpriv->ao_scan_vals = kmalloc_array(board->ao_chans,
sizeof(devpriv->ao_scan_vals[0]),
GFP_KERNEL);
if (!devpriv->ao_scan_vals)
return -ENOMEM;
/* Allocate buffer to hold AO channel scan order. */
devpriv->ao_scan_order = kmalloc(sizeof(devpriv->ao_scan_order[0]) *
board->ao_chans, GFP_KERNEL);
devpriv->ao_scan_order =
kmalloc_array(board->ao_chans,
sizeof(devpriv->ao_scan_order[0]),
GFP_KERNEL);
if (!devpriv->ao_scan_order)
return -ENOMEM;
......
......@@ -214,7 +214,8 @@ static int ni_670x_auto_attach(struct comedi_device *dev,
if (s->n_chan == 32) {
const struct comedi_lrange **range_table_list;
range_table_list = kmalloc(sizeof(struct comedi_lrange *) * 32,
range_table_list = kmalloc_array(32,
sizeof(struct comedi_lrange *),
GFP_KERNEL);
if (!range_table_list)
return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment