dev.dpdk.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] af_packet: fix memory allocation check
@ 2014-12-18  9:45 Daniel Mrzyglod
       [not found] ` <1418895905-915-1-git-send-email-danielx.t.mrzyglod-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Mrzyglod @ 2014-12-18  9:45 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

In rte_eth_af_packet.c we are we are missing NULL pointer
checks after calls to alocate memory for queues. Add checking NULL
pointer and error handling.

Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 lib/librte_pmd_af_packet/rte_eth_af_packet.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/librte_pmd_af_packet/rte_eth_af_packet.c b/lib/librte_pmd_af_packet/rte_eth_af_packet.c
index ad7242c..236749b 100644
--- a/lib/librte_pmd_af_packet/rte_eth_af_packet.c
+++ b/lib/librte_pmd_af_packet/rte_eth_af_packet.c
@@ -603,6 +603,8 @@ rte_pmd_init_internals(const char *name,
 		rdsize = req->tp_frame_nr * sizeof(*(rx_queue->rd));
 
 		rx_queue->rd = rte_zmalloc_socket(name, rdsize, 0, numa_node);
+		if (rx_queue->rd == NULL)
+			goto error;
 		for (i = 0; i < req->tp_frame_nr; ++i) {
 			rx_queue->rd[i].iov_base = rx_queue->map + (i * framesize);
 			rx_queue->rd[i].iov_len = req->tp_frame_size;
@@ -615,6 +617,8 @@ rte_pmd_init_internals(const char *name,
 		tx_queue->map = rx_queue->map + req->tp_block_size * req->tp_block_nr;
 
 		tx_queue->rd = rte_zmalloc_socket(name, rdsize, 0, numa_node);
+		if (tx_queue->rd == NULL)
+			goto error;
 		for (i = 0; i < req->tp_frame_nr; ++i) {
 			tx_queue->rd[i].iov_base = tx_queue->map + (i * framesize);
 			tx_queue->rd[i].iov_len = req->tp_frame_size;
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] af_packet: fix memory allocation check
@ 2014-12-18 10:51 Daniel Mrzyglod
       [not found] ` <1418899870-18588-1-git-send-email-danielx.t.mrzyglod-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Mrzyglod @ 2014-12-18 10:51 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

In rte_eth_af_packet.c we are we are missing NULL pointer
checks after calls to alocate memory for queues. Add checking NULL
pointer and error handling.

Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 lib/librte_pmd_af_packet/rte_eth_af_packet.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/librte_pmd_af_packet/rte_eth_af_packet.c b/lib/librte_pmd_af_packet/rte_eth_af_packet.c
index ad7242c..236749b 100644
--- a/lib/librte_pmd_af_packet/rte_eth_af_packet.c
+++ b/lib/librte_pmd_af_packet/rte_eth_af_packet.c
@@ -603,6 +603,8 @@ rte_pmd_init_internals(const char *name,
 		rdsize = req->tp_frame_nr * sizeof(*(rx_queue->rd));
 
 		rx_queue->rd = rte_zmalloc_socket(name, rdsize, 0, numa_node);
+		if (rx_queue->rd == NULL)
+			goto error;
 		for (i = 0; i < req->tp_frame_nr; ++i) {
 			rx_queue->rd[i].iov_base = rx_queue->map + (i * framesize);
 			rx_queue->rd[i].iov_len = req->tp_frame_size;
@@ -615,6 +617,8 @@ rte_pmd_init_internals(const char *name,
 		tx_queue->map = rx_queue->map + req->tp_block_size * req->tp_block_nr;
 
 		tx_queue->rd = rte_zmalloc_socket(name, rdsize, 0, numa_node);
+		if (tx_queue->rd == NULL)
+			goto error;
 		for (i = 0; i < req->tp_frame_nr; ++i) {
 			tx_queue->rd[i].iov_base = tx_queue->map + (i * framesize);
 			tx_queue->rd[i].iov_len = req->tp_frame_size;
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] af_packet: fix memory allocation check
       [not found] ` <1418899870-18588-1-git-send-email-danielx.t.mrzyglod-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
@ 2014-12-18 20:58   ` Thomas Monjalon
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Monjalon @ 2014-12-18 20:58 UTC (permalink / raw)
  To: Daniel Mrzyglod; +Cc: dev-VfR2kkLFssw

2014-12-18 10:51, Daniel Mrzyglod:
> In rte_eth_af_packet.c we are we are missing NULL pointer
> checks after calls to alocate memory for queues. Add checking NULL
> pointer and error handling.
> 
> Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

You sent this patch twice:
	http://dpdk.org/ml/archives/dev/2014-December/010331.html
	http://dpdk.org/ml/archives/dev/2014-December/010333.html

And you didn't send any patch for the part "Not munmaped queue area"
of your original patch:
	http://dpdk.org/ml/archives/dev/2014-December/010229.html

-- 
Thomas

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] af_packet: fix memory allocation check
       [not found] ` <1418895905-915-1-git-send-email-danielx.t.mrzyglod-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
@ 2014-12-18 21:15   ` Neil Horman
       [not found]     ` <20141218211512.GI18008-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Neil Horman @ 2014-12-18 21:15 UTC (permalink / raw)
  To: Daniel Mrzyglod; +Cc: dev-VfR2kkLFssw

On Thu, Dec 18, 2014 at 09:45:05AM +0000, Daniel Mrzyglod wrote:
> In rte_eth_af_packet.c we are we are missing NULL pointer
> checks after calls to alocate memory for queues. Add checking NULL
> pointer and error handling.
> 
> Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> ---
>  lib/librte_pmd_af_packet/rte_eth_af_packet.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/lib/librte_pmd_af_packet/rte_eth_af_packet.c b/lib/librte_pmd_af_packet/rte_eth_af_packet.c
> index ad7242c..236749b 100644
> --- a/lib/librte_pmd_af_packet/rte_eth_af_packet.c
> +++ b/lib/librte_pmd_af_packet/rte_eth_af_packet.c
> @@ -603,6 +603,8 @@ rte_pmd_init_internals(const char *name,
>  		rdsize = req->tp_frame_nr * sizeof(*(rx_queue->rd));
>  
>  		rx_queue->rd = rte_zmalloc_socket(name, rdsize, 0, numa_node);
> +		if (rx_queue->rd == NULL)
> +			goto error;
>  		for (i = 0; i < req->tp_frame_nr; ++i) {
>  			rx_queue->rd[i].iov_base = rx_queue->map + (i * framesize);
>  			rx_queue->rd[i].iov_len = req->tp_frame_size;
> @@ -615,6 +617,8 @@ rte_pmd_init_internals(const char *name,
>  		tx_queue->map = rx_queue->map + req->tp_block_size * req->tp_block_nr;
>  
>  		tx_queue->rd = rte_zmalloc_socket(name, rdsize, 0, numa_node);
> +		if (tx_queue->rd == NULL)
> +			goto error;
>  		for (i = 0; i < req->tp_frame_nr; ++i) {
>  			tx_queue->rd[i].iov_base = tx_queue->map + (i * framesize);
>  			tx_queue->rd[i].iov_len = req->tp_frame_size;
> -- 
> 2.1.0
> 
> 
Acked-by: Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] af_packet: fix memory allocation check
       [not found]     ` <20141218211512.GI18008-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org>
@ 2014-12-18 22:14       ` Thomas Monjalon
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Monjalon @ 2014-12-18 22:14 UTC (permalink / raw)
  To: Daniel Mrzyglod; +Cc: dev-VfR2kkLFssw

> > In rte_eth_af_packet.c we are we are missing NULL pointer
> > checks after calls to alocate memory for queues. Add checking NULL
> > pointer and error handling.
> > 
> > Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> 
> Acked-by: Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>

Applied

Thanks
-- 
Thomas

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-12-18 22:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-18  9:45 [PATCH] af_packet: fix memory allocation check Daniel Mrzyglod
     [not found] ` <1418895905-915-1-git-send-email-danielx.t.mrzyglod-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-12-18 21:15   ` Neil Horman
     [not found]     ` <20141218211512.GI18008-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org>
2014-12-18 22:14       ` Thomas Monjalon
  -- strict thread matches above, loose matches on Subject: below --
2014-12-18 10:51 Daniel Mrzyglod
     [not found] ` <1418899870-18588-1-git-send-email-danielx.t.mrzyglod-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-12-18 20:58   ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).