Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: Remove unnecessary OOM messages

alloc failures already get standardized OOM
messages and a dump_stack.

For the affected mallocs around these OOM messages:

Converted kzallocs with multiplies to kcalloc.
Converted kmallocs with multiplies to kmalloc_array.
Converted a kmalloc/strlen/strncpy to kstrdup.
Moved a spin_lock below a removed OOM message and
removed a now unnecessary spin_unlock.
Neatened alignment and whitespace.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Joe Perches and committed by
Greg Kroah-Hartman
78110bb8 ad463ac4

+143 -376
+3 -12
drivers/staging/asus_oled/asus_oled.c
··· 164 164 struct asus_oled_packet *packet; 165 165 166 166 packet = kzalloc(sizeof(struct asus_oled_packet), GFP_KERNEL); 167 - 168 - if (!packet) { 169 - dev_err(&odev->udev->dev, "out of memory\n"); 167 + if (!packet) 170 168 return; 171 - } 172 169 173 170 setup_packet_header(packet, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00); 174 171 ··· 320 323 struct asus_oled_packet *packet; 321 324 322 325 packet = kzalloc(sizeof(struct asus_oled_packet), GFP_KERNEL); 323 - 324 - if (!packet) { 325 - dev_err(&odev->udev->dev, "out of memory\n"); 326 + if (!packet) 326 327 return; 327 - } 328 328 329 329 if (odev->pack_mode == PACK_MODE_G1) { 330 330 /* When sending roll-mode data the display updated only ··· 659 665 } 660 666 661 667 odev = kzalloc(sizeof(struct asus_oled_dev), GFP_KERNEL); 662 - 663 - if (odev == NULL) { 664 - dev_err(&interface->dev, "Out of memory\n"); 668 + if (odev == NULL) 665 669 return -ENOMEM; 666 - } 667 670 668 671 odev->udev = usb_get_dev(udev); 669 672 odev->pic_mode = ASUS_OLED_STATIC;
+4 -10
drivers/staging/bcm/InterfaceInit.c
··· 190 190 } 191 191 192 192 /* Allocate interface adapter structure */ 193 - psIntfAdapter = kzalloc(sizeof(struct bcm_interface_adapter), GFP_KERNEL); 193 + psIntfAdapter = kzalloc(sizeof(struct bcm_interface_adapter), 194 + GFP_KERNEL); 194 195 if (psIntfAdapter == NULL) { 195 - dev_err(&udev->dev, DRV_NAME ": no memory for Interface adapter\n"); 196 196 AdapterFree(psAdapter); 197 197 return -ENOMEM; 198 198 } ··· 564 564 psIntfAdapter->sIntrIn.int_in_interval = endpoint->bInterval; 565 565 psIntfAdapter->sIntrIn.int_in_buffer = 566 566 kmalloc(buffer_size, GFP_KERNEL); 567 - if (!psIntfAdapter->sIntrIn.int_in_buffer) { 568 - dev_err(&psIntfAdapter->udev->dev, 569 - "could not allocate interrupt_in_buffer\n"); 567 + if (!psIntfAdapter->sIntrIn.int_in_buffer) 570 568 return -EINVAL; 571 - } 572 569 } 573 570 574 571 if (!psIntfAdapter->sIntrOut.int_out_endpointAddr && bcm_usb_endpoint_is_int_out(endpoint)) { ··· 584 587 psIntfAdapter->sIntrOut.int_out_endpointAddr = endpoint->bEndpointAddress; 585 588 psIntfAdapter->sIntrOut.int_out_interval = endpoint->bInterval; 586 589 psIntfAdapter->sIntrOut.int_out_buffer = kmalloc(buffer_size, GFP_KERNEL); 587 - if (!psIntfAdapter->sIntrOut.int_out_buffer) { 588 - dev_err(&psIntfAdapter->udev->dev, 589 - "could not allocate interrupt_out_buffer\n"); 590 + if (!psIntfAdapter->sIntrOut.int_out_buffer) 590 591 return -EINVAL; 591 - } 592 592 } 593 593 } 594 594 }
+1 -3
drivers/staging/ced1401/usb1401.c
··· 1391 1391 1392 1392 // allocate memory for our device extension and initialize it 1393 1393 pdx = kzalloc(sizeof(*pdx), GFP_KERNEL); 1394 - if (!pdx) { 1395 - dev_err(&interface->dev, "Out of memory\n"); 1394 + if (!pdx) 1396 1395 goto error; 1397 - } 1398 1396 1399 1397 for (i = 0; i < MAX_TRANSAREAS; ++i) // Initialise the wait queues 1400 1398 {
+2 -3
drivers/staging/comedi/drivers.c
··· 203 203 } 204 204 205 205 async = kzalloc(sizeof(*async), GFP_KERNEL); 206 - if (!async) { 207 - dev_warn(dev->class_dev, "failed to allocate async struct\n"); 206 + if (!async) 208 207 return -ENOMEM; 209 - } 208 + 210 209 init_waitqueue_head(&async->wait_head); 211 210 async->subdevice = s; 212 211 s->async = async;
+3 -6
drivers/staging/comedi/drivers/amplc_dio200.c
··· 1105 1105 struct dio200_subdev_intr *subpriv; 1106 1106 1107 1107 subpriv = kzalloc(sizeof(*subpriv), GFP_KERNEL); 1108 - if (!subpriv) { 1109 - dev_err(dev->class_dev, "error! out of memory!\n"); 1108 + if (!subpriv) 1110 1109 return -ENOMEM; 1111 - } 1110 + 1112 1111 subpriv->ofs = offset; 1113 1112 subpriv->valid_isns = valid_isns; 1114 1113 spin_lock_init(&subpriv->spinlock); ··· 1443 1444 unsigned int chan; 1444 1445 1445 1446 subpriv = kzalloc(sizeof(*subpriv), GFP_KERNEL); 1446 - if (!subpriv) { 1447 - dev_err(dev->class_dev, "error! out of memory!\n"); 1447 + if (!subpriv) 1448 1448 return -ENOMEM; 1449 - } 1450 1449 1451 1450 s->private = subpriv; 1452 1451 s->type = COMEDI_SUBD_COUNTER;
+2 -3
drivers/staging/comedi/drivers/comedi_bond.c
··· 245 245 return 0; 246 246 } 247 247 bdev = kmalloc(sizeof(*bdev), GFP_KERNEL); 248 - if (!bdev) { 249 - dev_err(dev->class_dev, "Out of memory\n"); 248 + if (!bdev) 250 249 return 0; 251 - } 250 + 252 251 bdev->dev = d; 253 252 bdev->minor = minor; 254 253 bdev->subdev = sdev;
+2 -3
drivers/staging/comedi/drivers/dt9812.c
··· 702 702 703 703 /* allocate memory for our device state and initialize it */ 704 704 dev = kzalloc(sizeof(*dev), GFP_KERNEL); 705 - if (dev == NULL) { 706 - dev_err(&interface->dev, "Out of memory\n"); 705 + if (dev == NULL) 707 706 goto error; 708 - } 707 + 709 708 kref_init(&dev->kref); 710 709 711 710 dev->udev = usb_get_dev(interface_to_usbdev(interface));
+4 -6
drivers/staging/comedi/drivers/ni_labpc.c
··· 570 570 return -EINVAL; 571 571 } else if (dma_chan) { 572 572 /* allocate dma buffer */ 573 - devpriv->dma_buffer = 574 - kmalloc(dma_buffer_size, GFP_KERNEL | GFP_DMA); 575 - if (devpriv->dma_buffer == NULL) { 576 - dev_err(dev->class_dev, 577 - "failed to allocate dma buffer\n"); 573 + devpriv->dma_buffer = kmalloc(dma_buffer_size, 574 + GFP_KERNEL | GFP_DMA); 575 + if (devpriv->dma_buffer == NULL) 578 576 return -ENOMEM; 579 - } 577 + 580 578 if (request_dma(dma_chan, DRV_NAME)) { 581 579 dev_err(dev->class_dev, 582 580 "failed to allocate dma channel %u\n",
+4 -7
drivers/staging/comedi/drivers/pcmuio.c
··· 838 838 839 839 chans_left = CHANS_PER_ASIC * board->num_asics; 840 840 n_subdevs = CALC_N_SUBDEVS(chans_left); 841 - devpriv->sprivs = 842 - kcalloc(n_subdevs, sizeof(struct pcmuio_subdev_private), 843 - GFP_KERNEL); 844 - if (!devpriv->sprivs) { 845 - dev_warn(dev->class_dev, 846 - "cannot allocate subdevice private data structures\n"); 841 + devpriv->sprivs = kcalloc(n_subdevs, 842 + sizeof(struct pcmuio_subdev_private), 843 + GFP_KERNEL); 844 + if (!devpriv->sprivs) 847 845 return -ENOMEM; 848 - } 849 846 850 847 ret = comedi_alloc_subdevices(dev, n_subdevs); 851 848 if (ret)
+1 -5
drivers/staging/comedi/drivers/unioxx5.c
··· 380 380 } 381 381 382 382 usp = kzalloc(sizeof(*usp), GFP_KERNEL); 383 - 384 - if (usp == NULL) { 385 - dev_err(subdev->class_dev, 386 - "comedi%d: error! --> out of memory!\n", minor); 383 + if (usp == NULL) 387 384 return -1; 388 - } 389 385 390 386 usp->usp_iobase = subdev_iobase; 391 387 dev_info(subdev->class_dev, "comedi%d: |", minor);
+4 -23
drivers/staging/comedi/drivers/usbdux.c
··· 2445 2445 /* create space for the commands of the DA converter */ 2446 2446 usbduxsub[index].dac_commands = kzalloc(NUMOUTCHANNELS, GFP_KERNEL); 2447 2447 if (!usbduxsub[index].dac_commands) { 2448 - dev_err(dev, "comedi_: usbdux: " 2449 - "error alloc space for dac commands\n"); 2450 2448 tidy_up(&(usbduxsub[index])); 2451 2449 up(&start_stop_sem); 2452 2450 return -ENOMEM; ··· 2452 2454 /* create space for the commands going to the usb device */ 2453 2455 usbduxsub[index].dux_commands = kzalloc(SIZEOFDUXBUFFER, GFP_KERNEL); 2454 2456 if (!usbduxsub[index].dux_commands) { 2455 - dev_err(dev, "comedi_: usbdux: " 2456 - "error alloc space for dux commands\n"); 2457 2457 tidy_up(&(usbduxsub[index])); 2458 2458 up(&start_stop_sem); 2459 2459 return -ENOMEM; ··· 2459 2463 /* create space for the in buffer and set it to zero */ 2460 2464 usbduxsub[index].inBuffer = kzalloc(SIZEINBUF, GFP_KERNEL); 2461 2465 if (!(usbduxsub[index].inBuffer)) { 2462 - dev_err(dev, "comedi_: usbdux: " 2463 - "could not alloc space for inBuffer\n"); 2464 2466 tidy_up(&(usbduxsub[index])); 2465 2467 up(&start_stop_sem); 2466 2468 return -ENOMEM; ··· 2466 2472 /* create space of the instruction buffer */ 2467 2473 usbduxsub[index].insnBuffer = kzalloc(SIZEINSNBUF, GFP_KERNEL); 2468 2474 if (!(usbduxsub[index].insnBuffer)) { 2469 - dev_err(dev, "comedi_: usbdux: " 2470 - "could not alloc space for insnBuffer\n"); 2471 2475 tidy_up(&(usbduxsub[index])); 2472 2476 up(&start_stop_sem); 2473 2477 return -ENOMEM; ··· 2473 2481 /* create space for the outbuffer */ 2474 2482 usbduxsub[index].outBuffer = kzalloc(SIZEOUTBUF, GFP_KERNEL); 2475 2483 if (!(usbduxsub[index].outBuffer)) { 2476 - dev_err(dev, "comedi_: usbdux: " 2477 - "could not alloc space for outBuffer\n"); 2478 2484 tidy_up(&(usbduxsub[index])); 2479 2485 up(&start_stop_sem); 2480 2486 return -ENOMEM; ··· 2494 2504 usbduxsub[index].numOfInBuffers = NUMOFINBUFFERSFULL; 2495 2505 2496 2506 usbduxsub[index].urbIn = 2497 - kzalloc(sizeof(struct urb *) * usbduxsub[index].numOfInBuffers, 2498 - GFP_KERNEL); 2507 + kcalloc(usbduxsub[index].numOfInBuffers, sizeof(struct urb *), 2508 + GFP_KERNEL); 2499 2509 if (!(usbduxsub[index].urbIn)) { 2500 - dev_err(dev, "comedi_: usbdux: Could not alloc. urbIn array\n"); 2501 2510 tidy_up(&(usbduxsub[index])); 2502 2511 up(&start_stop_sem); 2503 2512 return -ENOMEM; ··· 2521 2532 usbduxsub[index].urbIn[i]->transfer_buffer = 2522 2533 kzalloc(SIZEINBUF, GFP_KERNEL); 2523 2534 if (!(usbduxsub[index].urbIn[i]->transfer_buffer)) { 2524 - dev_err(dev, "comedi_: usbdux%d: " 2525 - "could not alloc. transb.\n", index); 2526 2535 tidy_up(&(usbduxsub[index])); 2527 2536 up(&start_stop_sem); 2528 2537 return -ENOMEM; ··· 2539 2552 usbduxsub[index].numOfOutBuffers = NUMOFOUTBUFFERSFULL; 2540 2553 2541 2554 usbduxsub[index].urbOut = 2542 - kzalloc(sizeof(struct urb *) * usbduxsub[index].numOfOutBuffers, 2543 - GFP_KERNEL); 2555 + kcalloc(usbduxsub[index].numOfOutBuffers, sizeof(struct urb *), 2556 + GFP_KERNEL); 2544 2557 if (!(usbduxsub[index].urbOut)) { 2545 - dev_err(dev, "comedi_: usbdux: " 2546 - "Could not alloc. urbOut array\n"); 2547 2558 tidy_up(&(usbduxsub[index])); 2548 2559 up(&start_stop_sem); 2549 2560 return -ENOMEM; ··· 2566 2581 usbduxsub[index].urbOut[i]->transfer_buffer = 2567 2582 kzalloc(SIZEOUTBUF, GFP_KERNEL); 2568 2583 if (!(usbduxsub[index].urbOut[i]->transfer_buffer)) { 2569 - dev_err(dev, "comedi_: usbdux%d: " 2570 - "could not alloc. transb.\n", index); 2571 2584 tidy_up(&(usbduxsub[index])); 2572 2585 up(&start_stop_sem); 2573 2586 return -ENOMEM; ··· 2600 2617 usbduxsub[index].urbPwm->transfer_buffer = 2601 2618 kzalloc(usbduxsub[index].sizePwmBuf, GFP_KERNEL); 2602 2619 if (!(usbduxsub[index].urbPwm->transfer_buffer)) { 2603 - dev_err(dev, "comedi_: usbdux%d: " 2604 - "could not alloc. transb. for pwm\n", index); 2605 2620 tidy_up(&(usbduxsub[index])); 2606 2621 up(&start_stop_sem); 2607 2622 return -ENOMEM;
-6
drivers/staging/comedi/drivers/usbduxfast.c
··· 1556 1556 usbduxfastsub[index].dux_commands = kmalloc(SIZEOFDUXBUFFER, 1557 1557 GFP_KERNEL); 1558 1558 if (!usbduxfastsub[index].dux_commands) { 1559 - dev_err(&uinterf->dev, 1560 - "error alloc space for dac commands\n"); 1561 1559 tidy_up(&(usbduxfastsub[index])); 1562 1560 up(&start_stop_sem); 1563 1561 return -ENOMEM; ··· 1563 1565 /* create space of the instruction buffer */ 1564 1566 usbduxfastsub[index].insnBuffer = kmalloc(SIZEINSNBUF, GFP_KERNEL); 1565 1567 if (!usbduxfastsub[index].insnBuffer) { 1566 - dev_err(&uinterf->dev, 1567 - "could not alloc space for insnBuffer\n"); 1568 1568 tidy_up(&(usbduxfastsub[index])); 1569 1569 up(&start_stop_sem); 1570 1570 return -ENOMEM; ··· 1588 1592 } 1589 1593 usbduxfastsub[index].transfer_buffer = kmalloc(SIZEINBUF, GFP_KERNEL); 1590 1594 if (!usbduxfastsub[index].transfer_buffer) { 1591 - dev_err(&uinterf->dev, 1592 - "usbduxfast%d: could not alloc. transb.\n", index); 1593 1595 tidy_up(&(usbduxfastsub[index])); 1594 1596 up(&start_stop_sem); 1595 1597 return -ENOMEM;
+5 -26
drivers/staging/comedi/drivers/usbduxsigma.c
··· 2431 2431 /* create space for the commands of the DA converter */ 2432 2432 usbduxsub[index].dac_commands = kzalloc(NUMOUTCHANNELS, GFP_KERNEL); 2433 2433 if (!usbduxsub[index].dac_commands) { 2434 - dev_err(dev, "comedi_: usbduxsigma: " 2435 - "error alloc space for dac commands\n"); 2436 2434 tidy_up(&(usbduxsub[index])); 2437 2435 up(&start_stop_sem); 2438 2436 return -ENOMEM; ··· 2438 2440 /* create space for the commands going to the usb device */ 2439 2441 usbduxsub[index].dux_commands = kzalloc(SIZEOFDUXBUFFER, GFP_KERNEL); 2440 2442 if (!usbduxsub[index].dux_commands) { 2441 - dev_err(dev, "comedi_: usbduxsigma: " 2442 - "error alloc space for dux commands\n"); 2443 2443 tidy_up(&(usbduxsub[index])); 2444 2444 up(&start_stop_sem); 2445 2445 return -ENOMEM; ··· 2445 2449 /* create space for the in buffer and set it to zero */ 2446 2450 usbduxsub[index].inBuffer = kzalloc(SIZEINBUF, GFP_KERNEL); 2447 2451 if (!(usbduxsub[index].inBuffer)) { 2448 - dev_err(dev, "comedi_: usbduxsigma: " 2449 - "could not alloc space for inBuffer\n"); 2450 2452 tidy_up(&(usbduxsub[index])); 2451 2453 up(&start_stop_sem); 2452 2454 return -ENOMEM; ··· 2452 2458 /* create space of the instruction buffer */ 2453 2459 usbduxsub[index].insnBuffer = kzalloc(SIZEINSNBUF, GFP_KERNEL); 2454 2460 if (!(usbduxsub[index].insnBuffer)) { 2455 - dev_err(dev, "comedi_: usbduxsigma: " 2456 - "could not alloc space for insnBuffer\n"); 2457 2461 tidy_up(&(usbduxsub[index])); 2458 2462 up(&start_stop_sem); 2459 2463 return -ENOMEM; ··· 2459 2467 /* create space for the outbuffer */ 2460 2468 usbduxsub[index].outBuffer = kzalloc(SIZEOUTBUF, GFP_KERNEL); 2461 2469 if (!(usbduxsub[index].outBuffer)) { 2462 - dev_err(dev, "comedi_: usbduxsigma: " 2463 - "could not alloc space for outBuffer\n"); 2464 2470 tidy_up(&(usbduxsub[index])); 2465 2471 up(&start_stop_sem); 2466 2472 return -ENOMEM; ··· 2479 2489 else 2480 2490 usbduxsub[index].numOfInBuffers = NUMOFINBUFFERSFULL; 2481 2491 2482 - usbduxsub[index].urbIn = 2483 - kzalloc(sizeof(struct urb *) * usbduxsub[index].numOfInBuffers, 2484 - GFP_KERNEL); 2492 + usbduxsub[index].urbIn = kcalloc(usbduxsub[index].numOfInBuffers, 2493 + sizeof(struct urb *), 2494 + GFP_KERNEL); 2485 2495 if (!(usbduxsub[index].urbIn)) { 2486 - dev_err(dev, "comedi_: usbduxsigma: " 2487 - "Could not alloc. urbIn array\n"); 2488 2496 tidy_up(&(usbduxsub[index])); 2489 2497 up(&start_stop_sem); 2490 2498 return -ENOMEM; ··· 2507 2519 usbduxsub[index].urbIn[i]->transfer_buffer = 2508 2520 kzalloc(SIZEINBUF, GFP_KERNEL); 2509 2521 if (!(usbduxsub[index].urbIn[i]->transfer_buffer)) { 2510 - dev_err(dev, "comedi_: usbduxsigma%d: " 2511 - "could not alloc. transb.\n", index); 2512 2522 tidy_up(&(usbduxsub[index])); 2513 2523 up(&start_stop_sem); 2514 2524 return -ENOMEM; ··· 2525 2539 else 2526 2540 usbduxsub[index].numOfOutBuffers = NUMOFOUTBUFFERSFULL; 2527 2541 2528 - usbduxsub[index].urbOut = 2529 - kzalloc(sizeof(struct urb *) * usbduxsub[index].numOfOutBuffers, 2530 - GFP_KERNEL); 2542 + usbduxsub[index].urbOut = kcalloc(usbduxsub[index].numOfOutBuffers, 2543 + sizeof(struct urb *), GFP_KERNEL); 2531 2544 if (!(usbduxsub[index].urbOut)) { 2532 - dev_err(dev, "comedi_: usbduxsigma: " 2533 - "Could not alloc. urbOut array\n"); 2534 2545 tidy_up(&(usbduxsub[index])); 2535 2546 up(&start_stop_sem); 2536 2547 return -ENOMEM; ··· 2552 2569 usbduxsub[index].urbOut[i]->transfer_buffer = 2553 2570 kzalloc(SIZEOUTBUF, GFP_KERNEL); 2554 2571 if (!(usbduxsub[index].urbOut[i]->transfer_buffer)) { 2555 - dev_err(dev, "comedi_: usbduxsigma%d: " 2556 - "could not alloc. transb.\n", index); 2557 2572 tidy_up(&(usbduxsub[index])); 2558 2573 up(&start_stop_sem); 2559 2574 return -ENOMEM; ··· 2587 2606 usbduxsub[index].urbPwm->transfer_buffer = 2588 2607 kzalloc(usbduxsub[index].sizePwmBuf, GFP_KERNEL); 2589 2608 if (!(usbduxsub[index].urbPwm->transfer_buffer)) { 2590 - dev_err(dev, "comedi_: usbduxsigma%d: " 2591 - "could not alloc. transb. for pwm\n", index); 2592 2609 tidy_up(&(usbduxsub[index])); 2593 2610 up(&start_stop_sem); 2594 2611 return -ENOMEM;
+1 -4
drivers/staging/cptm1217/clearpad_tm1217.c
··· 421 421 pdata = client->dev.platform_data; 422 422 423 423 ts = kzalloc(sizeof(struct cp_tm1217_device), GFP_KERNEL); 424 - if (!ts) { 425 - dev_err(&client->dev, 426 - "cp_tm1217: Private Device Struct alloc failed\n"); 424 + if (!ts) 427 425 return -ENOMEM; 428 - } 429 426 430 427 ts->client = client; 431 428 ts->dev = &client->dev;
+7 -13
drivers/staging/et131x/et131x.c
··· 2462 2462 /* Setup each RFD */ 2463 2463 for (rfdct = 0; rfdct < rx_ring->num_rfd; rfdct++) { 2464 2464 rfd = kzalloc(sizeof(struct rfd), GFP_ATOMIC | GFP_DMA); 2465 - 2466 - if (!rfd) { 2467 - dev_err(&adapter->pdev->dev, "Couldn't alloc RFD\n"); 2465 + if (!rfd) 2468 2466 return -ENOMEM; 2469 - } 2470 2467 2471 2468 rfd->skb = NULL; 2472 2469 ··· 2811 2814 struct tx_ring *tx_ring = &adapter->tx_ring; 2812 2815 2813 2816 /* Allocate memory for the TCB's (Transmit Control Block) */ 2814 - adapter->tx_ring.tcb_ring = 2815 - kcalloc(NUM_TCB, sizeof(struct tcb), GFP_ATOMIC | GFP_DMA); 2816 - if (!adapter->tx_ring.tcb_ring) { 2817 - dev_err(&adapter->pdev->dev, "Cannot alloc memory for TCBs\n"); 2817 + adapter->tx_ring.tcb_ring = kcalloc(NUM_TCB, sizeof(struct tcb), 2818 + GFP_ATOMIC | GFP_DMA); 2819 + if (!adapter->tx_ring.tcb_ring) 2818 2820 return -ENOMEM; 2819 - } 2820 2821 2821 2822 desc_size = (sizeof(struct tx_desc) * NUM_DESC_PER_RING_TX); 2822 2823 tx_ring->tx_desc_ring = ··· 4890 4895 adapter->mii_bus->read = et131x_mdio_read; 4891 4896 adapter->mii_bus->write = et131x_mdio_write; 4892 4897 adapter->mii_bus->reset = et131x_mdio_reset; 4893 - adapter->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL); 4894 - if (!adapter->mii_bus->irq) { 4895 - dev_err(&pdev->dev, "mii_bus irq allocation failed\n"); 4898 + adapter->mii_bus->irq = kmalloc_array(PHY_MAX_ADDR, sizeof(int), 4899 + GFP_KERNEL); 4900 + if (!adapter->mii_bus->irq) 4896 4901 goto err_mdio_free; 4897 - } 4898 4902 4899 4903 for (ii = 0; ii < PHY_MAX_ADDR; ii++) 4900 4904 adapter->mii_bus->irq[ii] = PHY_POLL;
+20 -31
drivers/staging/frontier/alphatrack.c
··· 678 678 /* allocate memory for our device state and initialize it */ 679 679 680 680 dev = kzalloc(sizeof(*dev), GFP_KERNEL); 681 - if (dev == NULL) { 682 - dev_err(&intf->dev, "Out of memory\n"); 681 + if (dev == NULL) 683 682 goto exit; 684 - } 683 + 685 684 mutex_init(&dev->mtx); 686 685 dev->intf = intf; 687 686 init_waitqueue_head(&dev->read_wait); ··· 720 721 721 722 /* FIXME - there are more usb_alloc routines for dma correctness. 722 723 Needed? */ 723 - dev->ring_buffer = 724 - kmalloc((true_size * sizeof(struct alphatrack_icmd)), GFP_KERNEL); 725 - 726 - if (!dev->ring_buffer) { 727 - dev_err(&intf->dev, 728 - "Couldn't allocate input ring_buffer of size %d\n", 729 - true_size); 724 + dev->ring_buffer = kmalloc_array(true_size, 725 + sizeof(struct alphatrack_icmd), 726 + GFP_KERNEL); 727 + if (!dev->ring_buffer) 730 728 goto error; 731 - } 732 729 733 - dev->interrupt_in_buffer = 734 - kmalloc(dev->interrupt_in_endpoint_size, GFP_KERNEL); 735 - 736 - if (!dev->interrupt_in_buffer) { 737 - dev_err(&intf->dev, "Couldn't allocate interrupt_in_buffer\n"); 730 + dev->interrupt_in_buffer = kmalloc(dev->interrupt_in_endpoint_size, 731 + GFP_KERNEL); 732 + if (!dev->interrupt_in_buffer) 738 733 goto error; 739 - } 734 + 740 735 dev->oldi_buffer = kmalloc(dev->interrupt_in_endpoint_size, GFP_KERNEL); 741 - if (!dev->oldi_buffer) { 742 - dev_err(&intf->dev, "Couldn't allocate old buffer\n"); 736 + if (!dev->oldi_buffer) 743 737 goto error; 744 - } 738 + 745 739 dev->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL); 746 740 if (!dev->interrupt_in_urb) { 747 741 dev_err(&intf->dev, "Couldn't allocate interrupt_in_urb\n"); ··· 756 764 true_size = min(write_buffer_size, WRITE_BUFFER_SIZE); 757 765 758 766 dev->interrupt_out_buffer = 759 - kmalloc(true_size * dev->interrupt_out_endpoint_size, GFP_KERNEL); 760 - 761 - if (!dev->interrupt_out_buffer) { 762 - dev_err(&intf->dev, "Couldn't allocate interrupt_out_buffer\n"); 767 + kmalloc_array(true_size, 768 + dev->interrupt_out_endpoint_size, 769 + GFP_KERNEL); 770 + if (!dev->interrupt_out_buffer) 763 771 goto error; 764 - } 765 772 766 - dev->write_buffer = 767 - kmalloc(true_size * sizeof(struct alphatrack_ocmd), GFP_KERNEL); 768 - 769 - if (!dev->write_buffer) { 770 - dev_err(&intf->dev, "Couldn't allocate write_buffer\n"); 773 + dev->write_buffer = kmalloc_array(true_size, 774 + sizeof(struct alphatrack_ocmd), 775 + GFP_KERNEL); 776 + if (!dev->write_buffer) 771 777 goto error; 772 - } 773 778 774 779 dev->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL); 775 780 if (!dev->interrupt_out_urb) {
+10 -16
drivers/staging/frontier/tranzport.c
··· 803 803 /* allocate memory for our device state and initialize it */ 804 804 805 805 dev = kzalloc(sizeof(*dev), GFP_KERNEL); 806 - if (dev == NULL) { 807 - dev_err(&intf->dev, "Out of memory\n"); 806 + if (dev == NULL) 808 807 goto exit; 809 - } 808 + 810 809 mutex_init(&dev->mtx); 811 810 dev->intf = intf; 812 811 init_waitqueue_head(&dev->read_wait); ··· 847 848 848 849 dev->ring_buffer = 849 850 kmalloc((true_size * sizeof(struct tranzport_cmd)) + 8, GFP_KERNEL); 850 - 851 - if (!dev->ring_buffer) { 852 - dev_err(&intf->dev, 853 - "Couldn't allocate ring_buffer size %d\n", true_size); 851 + if (!dev->ring_buffer) 854 852 goto error; 855 - } 853 + 856 854 dev->interrupt_in_buffer = 857 855 kmalloc(dev->interrupt_in_endpoint_size, GFP_KERNEL); 858 - if (!dev->interrupt_in_buffer) { 859 - dev_err(&intf->dev, "Couldn't allocate interrupt_in_buffer\n"); 856 + if (!dev->interrupt_in_buffer) 860 857 goto error; 861 - } 858 + 862 859 dev->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL); 863 860 if (!dev->interrupt_in_urb) { 864 861 dev_err(&intf->dev, "Couldn't allocate interrupt_in_urb\n"); ··· 870 875 "Interrupt out endpoint size is not 8!)\n"); 871 876 872 877 dev->interrupt_out_buffer = 873 - kmalloc(write_buffer_size * dev->interrupt_out_endpoint_size, 874 - GFP_KERNEL); 875 - if (!dev->interrupt_out_buffer) { 876 - dev_err(&intf->dev, "Couldn't allocate interrupt_out_buffer\n"); 878 + kmalloc_array(write_buffer_size, 879 + dev->interrupt_out_endpoint_size, GFP_KERNEL); 880 + if (!dev->interrupt_out_buffer) 877 881 goto error; 878 - } 882 + 879 883 dev->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL); 880 884 if (!dev->interrupt_out_urb) { 881 885 dev_err(&intf->dev, "Couldn't allocate interrupt_out_urb\n");
+1 -4
drivers/staging/ft1000/ft1000-usb/ft1000_usb.c
··· 68 68 const struct firmware *dsp_fw; 69 69 70 70 ft1000dev = kzalloc(sizeof(struct ft1000_usb), GFP_KERNEL); 71 - 72 - if (!ft1000dev) { 73 - pr_err("out of memory allocating device structure\n"); 71 + if (!ft1000dev) 74 72 return -ENOMEM; 75 - } 76 73 77 74 dev = interface_to_usbdev(interface); 78 75 DEBUG("ft1000_probe: usb device descriptor info:\n");
+2 -6
drivers/staging/gdm72xx/gdm_sdio.c
··· 156 156 spin_lock_init(&tx->lock); 157 157 158 158 tx->sdu_buf = kmalloc(SDU_TX_BUF_SIZE, GFP_KERNEL); 159 - if (tx->sdu_buf == NULL) { 160 - dev_err(&sdev->func->dev, "Failed to allocate SDU tx buffer.\n"); 159 + if (tx->sdu_buf == NULL) 161 160 goto fail; 162 - } 163 161 164 162 for (i = 0; i < MAX_NR_SDU_BUF; i++) { 165 163 t = alloc_tx_struct(tx); ··· 183 185 } 184 186 185 187 rx->rx_buf = kmalloc(RX_BUF_SIZE, GFP_KERNEL); 186 - if (rx->rx_buf == NULL) { 187 - dev_err(&sdev->func->dev, "Failed to allocate rx buffer.\n"); 188 + if (rx->rx_buf == NULL) 188 189 goto fail; 189 - } 190 190 191 191 return 0; 192 192
+2 -7
drivers/staging/gdm72xx/sdio_boot.c
··· 72 72 } 73 73 74 74 buf = kmalloc(DOWNLOAD_SIZE + TYPE_A_HEADER_SIZE, GFP_KERNEL); 75 - if (buf == NULL) { 76 - dev_err(&func->dev, "Error: kmalloc\n"); 75 + if (buf == NULL) 77 76 return -ENOMEM; 78 - } 79 77 80 78 img_len = firm->size; 81 79 ··· 139 141 const char *rfs_name = FW_DIR FW_RFS; 140 142 141 143 tx_buf = kmalloc(YMEM0_SIZE, GFP_KERNEL); 142 - if (tx_buf == NULL) { 143 - dev_err(&func->dev, "Error: kmalloc: %s %d\n", 144 - __func__, __LINE__); 144 + if (tx_buf == NULL) 145 145 return -ENOMEM; 146 - } 147 146 148 147 ret = download_image(func, krn_name); 149 148 if (ret)
+2 -6
drivers/staging/gdm72xx/usb_boot.c
··· 158 158 } 159 159 160 160 tx_buf = kmalloc(DOWNLOAD_SIZE, GFP_KERNEL); 161 - if (tx_buf == NULL) { 162 - dev_err(&usbdev->dev, "Error: kmalloc\n"); 161 + if (tx_buf == NULL) 163 162 return -ENOMEM; 164 - } 165 163 166 164 if (firm->size < sizeof(hdr)) { 167 165 dev_err(&usbdev->dev, "Cannot read the image info.\n"); ··· 299 301 } 300 302 301 303 buf = kmalloc(DOWNLOAD_CHUCK + pad_size, GFP_KERNEL); 302 - if (buf == NULL) { 303 - dev_err(&usbdev->dev, "Error: kmalloc\n"); 304 + if (buf == NULL) 304 305 return -ENOMEM; 305 - } 306 306 307 307 strcpy(buf+pad_size, type_string); 308 308 ret = gdm_wibro_send(usbdev, buf, strlen(type_string)+pad_size);
+1 -4
drivers/staging/iio/accel/lis3l02dq_ring.c
··· 140 140 char *data; 141 141 142 142 data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL); 143 - if (data == NULL) { 144 - dev_err(indio_dev->dev.parent, 145 - "memory alloc failed in buffer bh"); 143 + if (data == NULL) 146 144 goto done; 147 - } 148 145 149 146 if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength)) 150 147 len = lis3l02dq_get_buffer_element(indio_dev, data);
+2 -3
drivers/staging/keucr/usb.c
··· 266 266 } 267 267 268 268 us->sensebuf = kmalloc(US_SENSE_SIZE, GFP_KERNEL); 269 - if (!us->sensebuf) { 270 - pr_info("Sense buffer allocation failed\n"); 269 + if (!us->sensebuf) 271 270 return -ENOMEM; 272 - } 271 + 273 272 return 0; 274 273 } 275 274
+4 -21
drivers/staging/line6/driver.c
··· 233 233 234 234 /* create message: */ 235 235 msg = kmalloc(sizeof(struct message), GFP_ATOMIC); 236 - 237 - if (msg == NULL) { 238 - dev_err(line6->ifcdev, "Out of memory\n"); 236 + if (msg == NULL) 239 237 return -ENOMEM; 240 - } 241 238 242 239 /* create URB: */ 243 240 urb = usb_alloc_urb(0, GFP_ATOMIC); ··· 297 300 { 298 301 char *buffer = kmalloc(size + SYSEX_EXTRA_SIZE, GFP_ATOMIC); 299 302 300 - if (!buffer) { 301 - dev_err(line6->ifcdev, "out of memory\n"); 303 + if (!buffer) 302 304 return NULL; 303 - } 304 305 305 306 buffer[0] = LINE6_SYSEX_BEGIN; 306 307 memcpy(buffer + 1, line6_midi_id, sizeof(line6_midi_id)); ··· 398 403 int partial; 399 404 400 405 buffer = kmalloc(2, GFP_KERNEL); 401 - 402 - if (!buffer) { 403 - dev_err(line6->ifcdev, "out of memory\n"); 406 + if (!buffer) 404 407 return -ENOMEM; 405 - } 406 408 407 409 buffer[0] = LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_HOST; 408 410 buffer[1] = value; ··· 427 435 int partial; 428 436 429 437 buffer = kmalloc(3, GFP_KERNEL); 430 - 431 - if (!buffer) { 432 - dev_err(line6->ifcdev, "out of memory\n"); 438 + if (!buffer) 433 439 return -ENOMEM; 434 - } 435 440 436 441 buffer[0] = LINE6_PARAM_CHANGE | LINE6_CHANNEL_HOST; 437 442 buffer[1] = param; ··· 823 834 } 824 835 825 836 line6 = kzalloc(size, GFP_KERNEL); 826 - 827 837 if (line6 == NULL) { 828 - dev_err(&interface->dev, "Out of memory\n"); 829 838 ret = -ENODEV; 830 839 goto err_put; 831 840 } ··· 862 875 /* initialize USB buffers: */ 863 876 line6->buffer_listen = 864 877 kmalloc(LINE6_BUFSIZE_LISTEN, GFP_KERNEL); 865 - 866 878 if (line6->buffer_listen == NULL) { 867 - dev_err(&interface->dev, "Out of memory\n"); 868 879 ret = -ENOMEM; 869 880 goto err_destruct; 870 881 } 871 882 872 883 line6->buffer_message = 873 884 kmalloc(LINE6_MESSAGE_MAXLEN, GFP_KERNEL); 874 - 875 885 if (line6->buffer_message == NULL) { 876 - dev_err(&interface->dev, "Out of memory\n"); 877 886 ret = -ENOMEM; 878 887 goto err_destruct; 879 888 }
-6
drivers/staging/line6/pcm.c
··· 121 121 line6pcm->buffer_in = 122 122 kmalloc(LINE6_ISO_BUFFERS * LINE6_ISO_PACKETS * 123 123 line6pcm->max_packet_size, GFP_KERNEL); 124 - 125 124 if (!line6pcm->buffer_in) { 126 - dev_err(line6pcm->line6->ifcdev, 127 - "cannot malloc capture buffer\n"); 128 125 err = -ENOMEM; 129 126 goto pcm_acquire_error; 130 127 } ··· 157 160 line6pcm->buffer_out = 158 161 kmalloc(LINE6_ISO_BUFFERS * LINE6_ISO_PACKETS * 159 162 line6pcm->max_packet_size, GFP_KERNEL); 160 - 161 163 if (!line6pcm->buffer_out) { 162 - dev_err(line6pcm->line6->ifcdev, 163 - "cannot malloc playback buffer\n"); 164 164 err = -ENOMEM; 165 165 goto pcm_acquire_error; 166 166 }
+1 -3
drivers/staging/omapdrm/omap_connector.c
··· 261 261 omap_dss_get_device(dssdev); 262 262 263 263 omap_connector = kzalloc(sizeof(struct omap_connector), GFP_KERNEL); 264 - if (!omap_connector) { 265 - dev_err(dev->dev, "could not allocate connector\n"); 264 + if (!omap_connector) 266 265 goto fail; 267 - } 268 266 269 267 omap_connector->dssdev = dssdev; 270 268 omap_connector->encoder = encoder;
+1 -4
drivers/staging/omapdrm/omap_crtc.c
··· 601 601 DBG("%s", channel_names[channel]); 602 602 603 603 omap_crtc = kzalloc(sizeof(*omap_crtc), GFP_KERNEL); 604 - 605 - if (!omap_crtc) { 606 - dev_err(dev->dev, "could not allocate CRTC\n"); 604 + if (!omap_crtc) 607 605 goto fail; 608 - } 609 606 610 607 crtc = &omap_crtc->base; 611 608
+4 -9
drivers/staging/omapdrm/omap_dmm_tiler.c
··· 581 581 struct resource *mem; 582 582 583 583 omap_dmm = kzalloc(sizeof(*omap_dmm), GFP_KERNEL); 584 - if (!omap_dmm) { 585 - dev_err(&dev->dev, "failed to allocate driver data section\n"); 584 + if (!omap_dmm) 586 585 goto fail; 587 - } 588 586 589 587 /* initialize lists */ 590 588 INIT_LIST_HEAD(&omap_dmm->alloc_head); ··· 679 681 } 680 682 681 683 /* alloc engines */ 682 - omap_dmm->engines = kzalloc( 683 - omap_dmm->num_engines * sizeof(struct refill_engine), 684 - GFP_KERNEL); 684 + omap_dmm->engines = kcalloc(omap_dmm->num_engines, 685 + sizeof(struct refill_engine), GFP_KERNEL); 685 686 if (!omap_dmm->engines) { 686 - dev_err(&dev->dev, "could not allocate engines\n"); 687 687 ret = -ENOMEM; 688 688 goto fail; 689 689 } ··· 698 702 list_add(&omap_dmm->engines[i].idle_node, &omap_dmm->idle_head); 699 703 } 700 704 701 - omap_dmm->tcm = kzalloc(omap_dmm->num_lut * sizeof(*omap_dmm->tcm), 705 + omap_dmm->tcm = kcalloc(omap_dmm->num_lut, sizeof(*omap_dmm->tcm), 702 706 GFP_KERNEL); 703 707 if (!omap_dmm->tcm) { 704 - dev_err(&dev->dev, "failed to allocate lut ptrs\n"); 705 708 ret = -ENOMEM; 706 709 goto fail; 707 710 }
+1 -3
drivers/staging/omapdrm/omap_drv.c
··· 335 335 DBG("load: dev=%p", dev); 336 336 337 337 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 338 - if (!priv) { 339 - dev_err(dev->dev, "could not allocate priv\n"); 338 + if (!priv) 340 339 return -ENOMEM; 341 - } 342 340 343 341 priv->omaprev = pdata->omaprev; 344 342
+1 -3
drivers/staging/omapdrm/omap_encoder.c
··· 147 147 struct omap_encoder *omap_encoder; 148 148 149 149 omap_encoder = kzalloc(sizeof(*omap_encoder), GFP_KERNEL); 150 - if (!omap_encoder) { 151 - dev_err(dev->dev, "could not allocate encoder\n"); 150 + if (!omap_encoder) 152 151 goto fail; 153 - } 154 152 155 153 omap_encoder->dssdev = dssdev; 156 154
-1
drivers/staging/omapdrm/omap_fb.c
··· 418 418 419 419 omap_fb = kzalloc(sizeof(*omap_fb), GFP_KERNEL); 420 420 if (!omap_fb) { 421 - dev_err(dev->dev, "could not allocate fb\n"); 422 421 ret = -ENOMEM; 423 422 goto fail; 424 423 }
+1 -3
drivers/staging/omapdrm/omap_fbdev.c
··· 348 348 int ret = 0; 349 349 350 350 fbdev = kzalloc(sizeof(*fbdev), GFP_KERNEL); 351 - if (!fbdev) { 352 - dev_err(dev->dev, "could not allocate fbdev\n"); 351 + if (!fbdev) 353 352 goto fail; 354 - } 355 353 356 354 INIT_WORK(&fbdev->work, pan_worker); 357 355
+3 -7
drivers/staging/omapdrm/omap_gem.c
··· 1402 1402 } 1403 1403 1404 1404 omap_obj = kzalloc(sizeof(*omap_obj), GFP_KERNEL); 1405 - if (!omap_obj) { 1406 - dev_err(dev->dev, "could not allocate GEM object\n"); 1405 + if (!omap_obj) 1407 1406 goto fail; 1408 - } 1409 1407 1410 1408 list_add(&omap_obj->mm_list, &priv->obj_list); 1411 1409 ··· 1459 1461 return; 1460 1462 } 1461 1463 1462 - usergart = kzalloc(3 * sizeof(*usergart), GFP_KERNEL); 1463 - if (!usergart) { 1464 - dev_warn(dev->dev, "could not allocate usergart\n"); 1464 + usergart = kcalloc(3, sizeof(*usergart), GFP_KERNEL); 1465 + if (!usergart) 1465 1466 return; 1466 - } 1467 1467 1468 1468 /* reserve 4k aligned/wide regions for userspace mappings: */ 1469 1469 for (i = 0; i < ARRAY_SIZE(fmts); i++) {
+1 -3
drivers/staging/omapdrm/omap_plane.c
··· 390 390 DBG("%s: priv=%d", plane_names[id], private_plane); 391 391 392 392 omap_plane = kzalloc(sizeof(*omap_plane), GFP_KERNEL); 393 - if (!omap_plane) { 394 - dev_err(dev->dev, "could not allocate plane\n"); 393 + if (!omap_plane) 395 394 goto fail; 396 - } 397 395 398 396 ret = kfifo_alloc(&omap_plane->unpin_fifo, 16, GFP_KERNEL); 399 397 if (ret) {
+1 -3
drivers/staging/rtl8187se/ieee80211/ieee80211_module.c
··· 68 68 ieee->networks = kcalloc( 69 69 MAX_NETWORK_COUNT, sizeof(struct ieee80211_network), 70 70 GFP_KERNEL); 71 - if (!ieee->networks) { 72 - netdev_warn(ieee->dev, "Out of memory allocating beacons\n"); 71 + if (!ieee->networks) 73 72 return -ENOMEM; 74 - } 75 73 76 74 return 0; 77 75 }
+2 -4
drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c
··· 408 408 // if (memcmp(entry->mac, mac, ETH_ALEN)){ 409 409 if (p == &ieee->ibss_mac_hash[index]) { 410 410 entry = kmalloc(sizeof(struct ieee_ibss_seq), GFP_ATOMIC); 411 - if (!entry) { 412 - netdev_warn(ieee->dev, 413 - "Cannot malloc new mac entry\n"); 411 + if (!entry) 414 412 return 0; 415 - } 413 + 416 414 memcpy(entry->mac, mac, ETH_ALEN); 417 415 entry->seq_num[tid] = seq; 418 416 entry->frag_num[tid] = frag;
+3 -6
drivers/staging/sbe-2t3e3/dc.c
··· 315 315 struct sk_buff *m; 316 316 317 317 if (sc->ether.rx_ring == NULL) 318 - sc->ether.rx_ring = kzalloc(SBE_2T3E3_RX_DESC_RING_SIZE * 318 + sc->ether.rx_ring = kcalloc(SBE_2T3E3_RX_DESC_RING_SIZE, 319 319 sizeof(t3e3_rx_desc_t), GFP_KERNEL); 320 - if (sc->ether.rx_ring == NULL) { 321 - dev_err(&sc->pdev->dev, "SBE 2T3E3: no buffer space for RX ring\n"); 320 + if (sc->ether.rx_ring == NULL) 322 321 return -ENOMEM; 323 - } 324 322 325 323 if (sc->ether.tx_ring == NULL) 326 - sc->ether.tx_ring = kzalloc(SBE_2T3E3_TX_DESC_RING_SIZE * 324 + sc->ether.tx_ring = kcalloc(SBE_2T3E3_TX_DESC_RING_SIZE, 327 325 sizeof(t3e3_tx_desc_t), GFP_KERNEL); 328 326 if (sc->ether.tx_ring == NULL) { 329 327 kfree(sc->ether.rx_ring); 330 328 sc->ether.rx_ring = NULL; 331 - dev_err(&sc->pdev->dev, "SBE 2T3E3: no buffer space for RX ring\n"); 332 329 return -ENOMEM; 333 330 } 334 331
+3 -4
drivers/staging/sbe-2t3e3/module.c
··· 154 154 /* holds the reference for pdev1 */ 155 155 } 156 156 157 - card = kzalloc(sizeof(struct card) + channels * sizeof(struct channel), GFP_KERNEL); 158 - if (!card) { 159 - dev_err(&pdev->dev, "Out of memory\n"); 157 + card = kzalloc(sizeof(struct card) + channels * sizeof(struct channel), 158 + GFP_KERNEL); 159 + if (!card) 160 160 return -ENOBUFS; 161 - } 162 161 163 162 spin_lock_init(&card->bootrom_lock); 164 163 card->bootrom_addr = pci_resource_start(pdev, 0);
+2 -4
drivers/staging/sep/sep_crypto.c
··· 178 178 nbr_pages += 1; 179 179 } 180 180 181 - sg = kmalloc((sizeof(struct scatterlist) * nbr_pages), GFP_ATOMIC); 182 - if (!sg) { 183 - dev_warn(&sep->pdev->dev, "Cannot allocate page for new sg\n"); 181 + sg = kmalloc_array(nbr_pages, sizeof(struct scatterlist), GFP_ATOMIC); 182 + if (!sg) 184 183 return NULL; 185 - } 186 184 187 185 sg_init_table(sg, nbr_pages); 188 186
+12 -32
drivers/staging/sep/sep_main.c
··· 219 219 dev_dbg(&sep->pdev->dev, "[PID%d] oldlen = 0x%08X\n", current->pid, 220 220 dma_ctx->dmatables_len); 221 221 tmp_region = kzalloc(new_len + dma_ctx->dmatables_len, GFP_KERNEL); 222 - if (!tmp_region) { 223 - dev_warn(&sep->pdev->dev, 224 - "[PID%d] no mem for dma tables region\n", 225 - current->pid); 222 + if (!tmp_region) 226 223 return -ENOMEM; 227 - } 228 224 229 225 /* Were there any previous tables that need to be preserved ? */ 230 226 if (*dmatables_region) { ··· 1241 1245 current->pid, num_pages); 1242 1246 1243 1247 /* Allocate array of pages structure pointers */ 1244 - page_array = kmalloc(sizeof(struct page *) * num_pages, GFP_ATOMIC); 1248 + page_array = kmalloc_array(num_pages, sizeof(struct page *), 1249 + GFP_ATOMIC); 1245 1250 if (!page_array) { 1246 1251 error = -ENOMEM; 1247 1252 goto end_function; 1248 1253 } 1249 - map_array = kmalloc(sizeof(struct sep_dma_map) * num_pages, GFP_ATOMIC); 1254 + 1255 + map_array = kmalloc_array(num_pages, sizeof(struct sep_dma_map), 1256 + GFP_ATOMIC); 1250 1257 if (!map_array) { 1251 - dev_warn(&sep->pdev->dev, 1252 - "[PID%d] kmalloc for map_array failed\n", 1253 - current->pid); 1254 1258 error = -ENOMEM; 1255 1259 goto end_function_with_error1; 1256 1260 } 1257 1261 1258 - lli_array = kmalloc(sizeof(struct sep_lli_entry) * num_pages, 1259 - GFP_ATOMIC); 1260 - 1262 + lli_array = kmalloc_array(num_pages, sizeof(struct sep_lli_entry), 1263 + GFP_ATOMIC); 1261 1264 if (!lli_array) { 1262 - dev_warn(&sep->pdev->dev, 1263 - "[PID%d] kmalloc for lli_array failed\n", 1264 - current->pid); 1265 1265 error = -ENOMEM; 1266 1266 goto end_function_with_error2; 1267 1267 } ··· 1440 1448 dev_dbg(&sep->pdev->dev, "[PID%d] num_pages is (hex) %x\n", 1441 1449 current->pid, num_pages); 1442 1450 1443 - lli_array = kmalloc(sizeof(struct sep_lli_entry) * num_pages, 1444 - GFP_ATOMIC); 1445 - 1446 - if (!lli_array) { 1447 - dev_warn(&sep->pdev->dev, 1448 - "[PID%d] kmalloc for lli_array failed\n", 1449 - current->pid); 1451 + lli_array = kmalloc_array(num_pages, sizeof(struct sep_lli_entry), 1452 + GFP_ATOMIC); 1453 + if (!lli_array) 1450 1454 return -ENOMEM; 1451 - } 1452 1455 1453 1456 /* 1454 1457 * Fill the lli_array ··· 3406 3419 goto end_function; 3407 3420 } 3408 3421 3409 - dcb_args = kzalloc(num_dcbs * sizeof(struct build_dcb_struct), 3422 + dcb_args = kcalloc(num_dcbs, sizeof(struct build_dcb_struct), 3410 3423 GFP_KERNEL); 3411 3424 if (!dcb_args) { 3412 - dev_warn(&sep->pdev->dev, "[PID%d] no memory for dcb args\n", 3413 - current->pid); 3414 3425 error = -ENOMEM; 3415 3426 goto end_function; 3416 3427 } ··· 3595 3610 /* Allocate thread-specific memory for message buffer */ 3596 3611 *msg_region = kzalloc(msg_len, GFP_KERNEL); 3597 3612 if (!(*msg_region)) { 3598 - dev_warn(&sep->pdev->dev, 3599 - "[PID%d] no mem for msgarea context\n", 3600 - current->pid); 3601 3613 error = -ENOMEM; 3602 3614 goto end_function; 3603 3615 } ··· 4115 4133 /* Allocate the sep_device structure for this device */ 4116 4134 sep_dev = kzalloc(sizeof(struct sep_device), GFP_ATOMIC); 4117 4135 if (sep_dev == NULL) { 4118 - dev_warn(&pdev->dev, 4119 - "can't kmalloc the sep_device structure\n"); 4120 4136 error = -ENOMEM; 4121 4137 goto end_function_disable_device; 4122 4138 }
-1
drivers/staging/speakup/selection.c
··· 95 95 /* Allocate a new buffer before freeing the old one ... */ 96 96 bp = kmalloc((sel_end-sel_start)/2+1, GFP_ATOMIC); 97 97 if (!bp) { 98 - dev_warn(tty->dev, "selection: kmalloc() failed\n"); 99 98 speakup_clear_selection(); 100 99 return -ENOMEM; 101 100 }
+6 -12
drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c
··· 742 742 case SYNAPTICS_RMI4_TOUCHPAD_FUNC_NUM: 743 743 if (rmi_fd.intr_src_count) { 744 744 rfi = kmalloc(sizeof(*rfi), 745 - GFP_KERNEL); 746 - if (!rfi) { 747 - dev_err(&client->dev, 748 - "%s:kmalloc failed\n", 749 - __func__); 750 - return -ENOMEM; 751 - } 745 + GFP_KERNEL); 746 + if (!rfi) 747 + return -ENOMEM; 752 748 retval = synpatics_rmi4_touchpad_detect 753 749 (pdata, rfi, 754 750 &rmi_fd, ··· 896 900 } 897 901 898 902 /* Allocate and initialize the instance data for this client */ 899 - rmi4_data = kzalloc(sizeof(struct synaptics_rmi4_data) * 2, 900 - GFP_KERNEL); 901 - if (!rmi4_data) { 902 - dev_err(&client->dev, "%s: no memory allocated\n", __func__); 903 + rmi4_data = kcalloc(2, sizeof(struct synaptics_rmi4_data), 904 + GFP_KERNEL); 905 + if (!rmi4_data) 903 906 return -ENOMEM; 904 - } 905 907 906 908 rmi4_data->input_dev = input_allocate_device(); 907 909 if (rmi4_data->input_dev == NULL) {
+1 -1
drivers/staging/tidspbridge/pmgr/dspapi.c
··· 1543 1543 if (num_bufs > MAX_BUFS) 1544 1544 return -EINVAL; 1545 1545 1546 - ap_buffer = kmalloc((num_bufs * sizeof(u8 *)), GFP_KERNEL); 1546 + ap_buffer = kmalloc_array(num_bufs, sizeof(u8 *), GFP_KERNEL); 1547 1547 if (ap_buffer == NULL) 1548 1548 return -ENOMEM; 1549 1549
+5 -12
drivers/staging/tidspbridge/rmgr/proc.c
··· 119 119 dsp_addr, size); 120 120 121 121 map_obj = kzalloc(sizeof(struct dmm_map_object), GFP_KERNEL); 122 - if (!map_obj) { 123 - pr_err("%s: kzalloc failed\n", __func__); 122 + if (!map_obj) 124 123 return NULL; 125 - } 124 + 126 125 INIT_LIST_HEAD(&map_obj->link); 127 126 128 127 map_obj->pages = kcalloc(num_usr_pgs, sizeof(struct page *), 129 - GFP_KERNEL); 128 + GFP_KERNEL); 130 129 if (!map_obj->pages) { 131 - pr_err("%s: kzalloc failed\n", __func__); 132 130 kfree(map_obj); 133 131 return NULL; 134 132 } ··· 691 693 692 694 sg = kcalloc(num_pages, sizeof(*sg), GFP_KERNEL); 693 695 if (!sg) { 694 - pr_err("%s: kcalloc failed\n", __func__); 695 696 ret = -ENOMEM; 696 697 goto out; 697 698 } ··· 1224 1227 (p_proc_object->bridge_context, &brd_state))) { 1225 1228 pr_info("%s: Processor Loaded %s\n", __func__, pargv0); 1226 1229 kfree(drv_datap->base_img); 1227 - drv_datap->base_img = kmalloc(strlen(pargv0) + 1, 1228 - GFP_KERNEL); 1229 - if (drv_datap->base_img) 1230 - strncpy(drv_datap->base_img, pargv0, 1231 - strlen(pargv0) + 1); 1232 - else 1230 + drv_datap->base_img = kstrdup(pargv0, GFP_KERNEL); 1231 + if (!drv_datap->base_img) 1233 1232 status = -ENOMEM; 1234 1233 } 1235 1234 }
+1 -3
drivers/staging/usbip/stub_dev.c
··· 286 286 287 287 /* yes, it's a new device */ 288 288 sdev = kzalloc(sizeof(struct stub_device), GFP_KERNEL); 289 - if (!sdev) { 290 - dev_err(&interface->dev, "no memory for stub_device\n"); 289 + if (!sdev) 291 290 return NULL; 292 - } 293 291 294 292 sdev->interface = usb_get_intf(interface); 295 293 sdev->udev = usb_get_dev(udev);
-1
drivers/staging/usbip/stub_rx.c
··· 485 485 kzalloc(pdu->u.cmd_submit.transfer_buffer_length, 486 486 GFP_KERNEL); 487 487 if (!priv->urb->transfer_buffer) { 488 - dev_err(&sdev->interface->dev, "malloc x_buff\n"); 489 488 usbip_event_add(ud, SDEV_EVENT_ERROR_MALLOC); 490 489 return; 491 490 }
-1
drivers/staging/usbip/stub_tx.c
··· 42 42 43 43 unlink = kzalloc(sizeof(struct stub_unlink), GFP_ATOMIC); 44 44 if (!unlink) { 45 - dev_err(&sdev->interface->dev, "alloc stub_unlink\n"); 46 45 usbip_event_add(&sdev->ud, VDEV_EVENT_ERROR_MALLOC); 47 46 return; 48 47 }
+2 -6
drivers/staging/usbip/vhci_hcd.c
··· 434 434 } 435 435 436 436 priv = kzalloc(sizeof(struct vhci_priv), GFP_ATOMIC); 437 - 438 - spin_lock(&vdev->priv_lock); 439 - 440 437 if (!priv) { 441 - dev_err(&urb->dev->dev, "malloc vhci_priv\n"); 442 - spin_unlock(&vdev->priv_lock); 443 438 usbip_event_add(&vdev->ud, VDEV_EVENT_ERROR_MALLOC); 444 439 return; 445 440 } 441 + 442 + spin_lock(&vdev->priv_lock); 446 443 447 444 priv->seqnum = atomic_inc_return(&the_controller->seqnum); 448 445 if (priv->seqnum == 0xffff) ··· 681 684 /* setup CMD_UNLINK pdu */ 682 685 unlink = kzalloc(sizeof(struct vhci_unlink), GFP_ATOMIC); 683 686 if (!unlink) { 684 - pr_err("malloc vhci_unlink\n"); 685 687 spin_unlock(&vdev->priv_lock); 686 688 spin_unlock(&the_controller->lock); 687 689 usbip_event_add(&vdev->ud, VDEV_EVENT_ERROR_MALLOC);
-1
drivers/staging/vme/devices/vme_pio2_core.c
··· 222 222 223 223 card = kzalloc(sizeof(struct pio2_card), GFP_KERNEL); 224 224 if (card == NULL) { 225 - dev_err(&vdev->dev, "Unable to allocate card structure\n"); 226 225 retval = -ENOMEM; 227 226 goto err_struct; 228 227 }
+1 -3
drivers/staging/vme/devices/vme_pio2_gpio.c
··· 192 192 char *label; 193 193 194 194 label = kmalloc(PIO2_NUM_CHANNELS, GFP_KERNEL); 195 - if (label == NULL) { 196 - dev_err(&card->vdev->dev, "Unable to allocate GPIO label\n"); 195 + if (label == NULL) 197 196 return -ENOMEM; 198 - } 199 197 200 198 sprintf(label, "%s@%s", driver_name, dev_name(&card->vdev->dev)); 201 199 card->gc.label = label;
-2
drivers/staging/vme/devices/vme_user.c
··· 761 761 image[i].size_buf = PCI_BUF_SIZE; 762 762 image[i].kern_buf = kmalloc(image[i].size_buf, GFP_KERNEL); 763 763 if (image[i].kern_buf == NULL) { 764 - dev_warn(&vdev->dev, 765 - "Unable to allocate memory for master window buffers\n"); 766 764 err = -ENOMEM; 767 765 goto err_master_buf; 768 766 }
+3 -6
drivers/staging/zcache/zcache-main.c
··· 1304 1304 goto out; 1305 1305 atomic_inc(&cli->refcount); 1306 1306 pool = kmalloc(sizeof(struct tmem_pool), GFP_ATOMIC); 1307 - if (pool == NULL) { 1308 - pr_info("%s: pool creation failed: out of memory\n", namestr); 1307 + if (pool == NULL) 1309 1308 goto out; 1310 - } 1311 1309 1312 1310 for (poolid = 0; poolid < MAX_POOLS_PER_CLIENT; poolid++) 1313 1311 if (cli->tmem_pools[poolid] == NULL) ··· 1378 1380 goto out; 1379 1381 } 1380 1382 pool = kmalloc(sizeof(struct tmem_pool), GFP_KERNEL); 1381 - if (pool == NULL) { 1382 - pr_info("%s: pool creation failed: out of memory\n", namestr); 1383 + if (pool == NULL) 1383 1384 goto out; 1384 - } 1385 + 1385 1386 atomic_set(&pool->refcount, 0); 1386 1387 pool->client = cli; 1387 1388 pool->pool_id = pool_id;
+1 -4
drivers/staging/zram/zram_drv.c
··· 246 246 */ 247 247 uncmem = kmalloc(PAGE_SIZE, GFP_NOIO); 248 248 if (!uncmem) { 249 - pr_info("Error allocating temp memory!\n"); 250 249 ret = -ENOMEM; 251 250 goto out; 252 251 } ··· 516 517 goto out; 517 518 518 519 meta->compress_workmem = kzalloc(LZO1X_MEM_COMPRESS, GFP_KERNEL); 519 - if (!meta->compress_workmem) { 520 - pr_err("Error allocating compressor working memory!\n"); 520 + if (!meta->compress_workmem) 521 521 goto free_meta; 522 - } 523 522 524 523 meta->compress_buffer = 525 524 (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, 1);