Skip to content

Commit fa1a6c9

Browse files
Aleksey Makarovdavem330
authored andcommitted
net: thunderx: check if memory allocation was successful
This fixes a coccinelle warning: coccinelle warnings: (new ones prefixed by >>) >> drivers/net/ethernet/cavium/thunder/nicvf_queues.c:360:1-11: alloc >> with no test, possible model on line 367 vim +360 drivers/net/ethernet/cavium/thunder/nicvf_queues.c 354 err = nicvf_alloc_q_desc_mem(nic, &sq->dmem, q_len, SND_QUEUE_DESC_SIZE, 355 NICVF_SQ_BASE_ALIGN_BYTES); 356 if (err) 357 return err; 358 359 sq->desc = sq->dmem.base; > 360 sq->skbuff = kcalloc(q_len, sizeof(u64), GFP_ATOMIC); 361 sq->head = 0; 362 sq->tail = 0; 363 atomic_set(&sq->free_cnt, q_len - 1); 364 sq->thresh = SND_QUEUE_THRESH; 365 366 /* Preallocate memory for TSO segment's header */ > 367 sq->tso_hdrs = dma_alloc_coherent(&nic->pdev->dev, 368 q_len * TSO_HEADER_SIZE, 369 &sq->tso_hdrs_phys, GFP_KERNEL); 370 if (!sq->tso_hdrs) Reported-by: kbuild test robot <[email protected]> Signed-off-by: Aleksey Makarov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 39a0dd0 commit fa1a6c9

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/net/ethernet/cavium/thunder/nicvf_queues.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,8 @@ static int nicvf_init_snd_queue(struct nicvf *nic,
357357

358358
sq->desc = sq->dmem.base;
359359
sq->skbuff = kcalloc(q_len, sizeof(u64), GFP_ATOMIC);
360+
if (!sq->skbuff)
361+
return -ENOMEM;
360362
sq->head = 0;
361363
sq->tail = 0;
362364
atomic_set(&sq->free_cnt, q_len - 1);

0 commit comments

Comments
 (0)