Skip to contentSkip to conversation

staging: comedi: das1800: prefer kmalloc_array over kmalloc with multiply

PATCH In review Chase Southwood 2 participants 2 messages Jan 20, 2015 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: comedi: das1800: prefer kmalloc_array over kmalloc with multiply

Checkpatch doesn't like kmalloc with multiply very much:
drivers/staging/comedi/drivers/das1800.c:1377: WARNING: Prefer kmalloc_array over kmalloc with multiply

So this patch swaps that use out for kmalloc_array instead.

---
 drivers/staging/comedi/drivers/das1800.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/comedi/drivers/das1800.c +1 -1
index 381ae94..13ed31c 100644
@@ -1374,7 +1374,7 @@ static int das1800_attach(struct comedi_device *dev,
 	if (dev->irq & it->options[2])
 		das1800_init_dma(dev, it);
 
-	devpriv->fifo_buf = kmalloc(FIFO_SIZE * sizeof(uint16_t), GFP_KERNEL);
+	devpriv->fifo_buf = kmalloc_array(FIFO_SIZE, sizeof(uint16_t), GFP_KERNEL);
 	if (!devpriv->fifo_buf)
 		return -ENOMEM;
 
Signature · 1 line
2.2.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines · Chase Southwood

Checkpatch doesn't like kmalloc with multiply very much:
drivers/staging/comedi/drivers/das1800.c:1377: WARNING: Prefer kmalloc_array over kmalloc with multiply

So this patch swaps that use out for kmalloc_array instead.

---
  drivers/staging/comedi/drivers/das1800.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/comedi/drivers/das1800.c +0 -0
index 381ae94..13ed31c 100644

drivers/staging/comedi/drivers/das1800.c static int das1800_attach(struct comedi_device *dev, · line 1380

Quoted 8 lines
drivers/staging/comedi/drivers/das1800.c +1 -1
@@ -1374,7 +1374,7 @@ static int das1800_attach(struct comedi_device *dev,
  	if (dev->irq & it->options[2])
  		das1800_init_dma(dev, it);
 
-	devpriv->fifo_buf = kmalloc(FIFO_SIZE * sizeof(uint16_t), GFP_KERNEL);
+	devpriv->fifo_buf = kmalloc_array(FIFO_SIZE, sizeof(uint16_t), GFP_KERNEL);
  	if (!devpriv->fifo_buf)
  		return -ENOMEM;
 
Signature · 2 lines
-=( Ian Abbott @ MEV Ltd.    E-mail: <[email protected]> )=-
-=(                          Web: http://www.mev.co.uk/  )=-