lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1433268028-23992-10-git-send-email-aleksey.makarov@caviumnetworks.com>
Date:	Tue, 2 Jun 2015 11:00:26 -0700
From:	Aleksey Makarov <aleksey.makarov@...iumnetworks.com>
To:	<netdev@...r.kernel.org>
CC:	<linux-kernel@...r.kernel.org>,
	<linux-arm-kernel@...ts.infradead.org>,
	David Daney <david.daney@...ium.com>,
	Robert Richter <robert.richter@...iumnetworks.com>,
	Aleksey Makarov <aleksey.makarov@...iumnetworks.com>,
	Sunil Goutham <sgoutham@...ium.com>,
	Robert Richter <rric@...nel.org>
Subject: [PATCH 09/10] 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 <fengguang.wu@...el.com>
Signed-off-by: Aleksey Makarov <aleksey.makarov@...iumnetworks.com>
---
 drivers/net/ethernet/cavium/thunder/nicvf_queues.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c
index 8929029..2ed7d1b 100644
--- a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c
+++ b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c
@@ -357,6 +357,8 @@ static int nicvf_init_snd_queue(struct nicvf *nic,
 
 	sq->desc = sq->dmem.base;
 	sq->skbuff = kcalloc(q_len, sizeof(u64), GFP_ATOMIC);
+	if (!sq->skbuff)
+		return -ENOMEM;
 	sq->head = 0;
 	sq->tail = 0;
 	atomic_set(&sq->free_cnt, q_len - 1);
-- 
2.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ