DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/2] static matcher cleanups
@ 2015-07-16 23:47 Stephen Hemminger
  2015-07-16 23:47 ` [dpdk-dev] [PATCH 1/2] rte_ethdev: fix crash if malloc fails in rte_eth_dev_callback_register Stephen Hemminger
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Stephen Hemminger @ 2015-07-16 23:47 UTC (permalink / raw)
  To: dev

These were found by running the Linux kernel coccinelle scripts
on the DPDK source.

Stephen Hemminger (2):
  rte_ethdev: fix crash if malloc fails in rte_eth_dev_callback_register
  kni: fix coccinelle warnings

 lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c | 4 ++--
 lib/librte_eal/linuxapp/kni/kni_vhost.c            | 8 +++-----
 lib/librte_ether/rte_ethdev.c                      | 7 ++++---
 3 files changed, 9 insertions(+), 10 deletions(-)

-- 
2.1.4

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

* [dpdk-dev] [PATCH 1/2] rte_ethdev: fix crash if malloc fails in rte_eth_dev_callback_register
  2015-07-16 23:47 [dpdk-dev] [PATCH 0/2] static matcher cleanups Stephen Hemminger
@ 2015-07-16 23:47 ` Stephen Hemminger
  2015-07-17  8:16   ` Bruce Richardson
  2015-07-16 23:47 ` [dpdk-dev] [PATCH 2/2] kni: fix coccinelle warnings Stephen Hemminger
  2015-07-22 14:25 ` [dpdk-dev] [PATCH 0/2] static matcher cleanups Thomas Monjalon
  2 siblings, 1 reply; 6+ messages in thread
From: Stephen Hemminger @ 2015-07-16 23:47 UTC (permalink / raw)
  To: dev

Found by coccinelle script.  If rte_zmalloc() failed in rte_eth_dev_callback_register
then NULL pointer would be dereferenced.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/librte_ether/rte_ethdev.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index ddf3658..aa363be 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -2929,9 +2929,10 @@ rte_eth_dev_callback_register(uint8_t port_id,
 	}
 
 	/* create a new callback. */
-	if (user_cb == NULL &&
-	    (user_cb = rte_zmalloc("INTR_USER_CALLBACK",
-				   sizeof(struct rte_eth_dev_callback), 0))) {
+	if (!user_cb)
+	    user_cb = rte_zmalloc("INTR_USER_CALLBACK",
+				  sizeof(struct rte_eth_dev_callback), 0);
+	if (user_cb) {
 		user_cb->cb_fn = cb_fn;
 		user_cb->cb_arg = cb_arg;
 		user_cb->event = event;
-- 
2.1.4

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

* [dpdk-dev] [PATCH 2/2] kni: fix coccinelle warnings
  2015-07-16 23:47 [dpdk-dev] [PATCH 0/2] static matcher cleanups Stephen Hemminger
  2015-07-16 23:47 ` [dpdk-dev] [PATCH 1/2] rte_ethdev: fix crash if malloc fails in rte_eth_dev_callback_register Stephen Hemminger
@ 2015-07-16 23:47 ` Stephen Hemminger
  2015-07-22 14:25 ` [dpdk-dev] [PATCH 0/2] static matcher cleanups Thomas Monjalon
  2 siblings, 0 replies; 6+ messages in thread
From: Stephen Hemminger @ 2015-07-16 23:47 UTC (permalink / raw)
  To: dev

This fixes cases in KNI where kernel allocation function return value
is needlessly casted.

lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c:3181:25-28: WARNING: casting value returned by memory allocation function to (u32 *) is useless.
lib/librte_eal/linuxapp/kni/kni_vhost.c:690:9-28: WARNING: casting value returned by memory allocation function to (struct rte_kni_fifo *) is useless.
lib/librte_eal/linuxapp/kni/kni_vhost.c:684:13-27: WARNING: casting value returned by memory allocation function to (struct sk_buff *) is useless

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c | 4 ++--
 lib/librte_eal/linuxapp/kni/kni_vhost.c            | 8 +++-----
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c b/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c
index 47198bb..eed8df6 100644
--- a/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c
+++ b/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c
@@ -3178,8 +3178,8 @@ static int igb_sw_init(struct igb_adapter *adapter)
 				     GFP_ATOMIC);
 
 	/* Setup and initialize a copy of the hw vlan table array */
-	adapter->shadow_vfta = (u32 *)kzalloc(sizeof(u32) * E1000_VFTA_ENTRIES,
-					GFP_ATOMIC);
+	adapter->shadow_vfta = kzalloc(sizeof(u32) * E1000_VFTA_ENTRIES,
+				       GFP_ATOMIC);
 #ifdef NO_KNI
 	/* These calls may decrease the number of queues */
 	if (hw->mac.type < e1000_i210) {
diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index 013a677..d0c12a6 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -681,14 +681,12 @@ kni_vhost_backend_init(struct kni_dev *kni)
 	}
 
 	/* cache init */
-	q->cache = (struct sk_buff*)
-		kzalloc(RTE_KNI_VHOST_MAX_CACHE_SIZE * sizeof(struct sk_buff),
-			GFP_KERNEL);
+	q->cache = kzalloc(RTE_KNI_VHOST_MAX_CACHE_SIZE * sizeof(struct sk_buff),
+			   GFP_KERNEL);
 	if (!q->cache)
 		goto free_fd;
 
-	fifo = (struct rte_kni_fifo*)
-		kzalloc(RTE_KNI_VHOST_MAX_CACHE_SIZE * sizeof(void *)
+	fifo = kzalloc(RTE_KNI_VHOST_MAX_CACHE_SIZE * sizeof(void *)
 			+ sizeof(struct rte_kni_fifo), GFP_KERNEL);
 	if (!fifo)
 		goto free_cache;
-- 
2.1.4

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

* Re: [dpdk-dev] [PATCH 1/2] rte_ethdev: fix crash if malloc fails in rte_eth_dev_callback_register
  2015-07-16 23:47 ` [dpdk-dev] [PATCH 1/2] rte_ethdev: fix crash if malloc fails in rte_eth_dev_callback_register Stephen Hemminger
@ 2015-07-17  8:16   ` Bruce Richardson
  2015-07-22 13:54     ` Thomas Monjalon
  0 siblings, 1 reply; 6+ messages in thread
From: Bruce Richardson @ 2015-07-17  8:16 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

On Thu, Jul 16, 2015 at 04:47:23PM -0700, Stephen Hemminger wrote:
> Found by coccinelle script.  If rte_zmalloc() failed in rte_eth_dev_callback_register
> then NULL pointer would be dereferenced.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  lib/librte_ether/rte_ethdev.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
> index ddf3658..aa363be 100644
> --- a/lib/librte_ether/rte_ethdev.c
> +++ b/lib/librte_ether/rte_ethdev.c
> @@ -2929,9 +2929,10 @@ rte_eth_dev_callback_register(uint8_t port_id,
>  	}
>  
>  	/* create a new callback. */
> -	if (user_cb == NULL &&
> -	    (user_cb = rte_zmalloc("INTR_USER_CALLBACK",
> -				   sizeof(struct rte_eth_dev_callback), 0))) {
> +	if (!user_cb)

Minor style issue. Since user_cb is a pointer, not a boolean, the condition
should use "== NULL" rather than "!".

/Bruce

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

* Re: [dpdk-dev] [PATCH 1/2] rte_ethdev: fix crash if malloc fails in rte_eth_dev_callback_register
  2015-07-17  8:16   ` Bruce Richardson
@ 2015-07-22 13:54     ` Thomas Monjalon
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Monjalon @ 2015-07-22 13:54 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

2015-07-17 09:16, Bruce Richardson:
> On Thu, Jul 16, 2015 at 04:47:23PM -0700, Stephen Hemminger wrote:
> > -	if (user_cb == NULL &&
> > -	    (user_cb = rte_zmalloc("INTR_USER_CALLBACK",
> > -				   sizeof(struct rte_eth_dev_callback), 0))) {
> > +	if (!user_cb)
> 
> Minor style issue. Since user_cb is a pointer, not a boolean, the condition
> should use "== NULL" rather than "!".

Fixed before pushing.

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

* Re: [dpdk-dev] [PATCH 0/2] static matcher cleanups
  2015-07-16 23:47 [dpdk-dev] [PATCH 0/2] static matcher cleanups Stephen Hemminger
  2015-07-16 23:47 ` [dpdk-dev] [PATCH 1/2] rte_ethdev: fix crash if malloc fails in rte_eth_dev_callback_register Stephen Hemminger
  2015-07-16 23:47 ` [dpdk-dev] [PATCH 2/2] kni: fix coccinelle warnings Stephen Hemminger
@ 2015-07-22 14:25 ` Thomas Monjalon
  2 siblings, 0 replies; 6+ messages in thread
From: Thomas Monjalon @ 2015-07-22 14:25 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

2015-07-16 16:47, Stephen Hemminger:
> These were found by running the Linux kernel coccinelle scripts
> on the DPDK source.
> 
> Stephen Hemminger (2):
>   rte_ethdev: fix crash if malloc fails in rte_eth_dev_callback_register
>   kni: fix coccinelle warnings

Applied, thanks

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

end of thread, other threads:[~2015-07-22 14:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-16 23:47 [dpdk-dev] [PATCH 0/2] static matcher cleanups Stephen Hemminger
2015-07-16 23:47 ` [dpdk-dev] [PATCH 1/2] rte_ethdev: fix crash if malloc fails in rte_eth_dev_callback_register Stephen Hemminger
2015-07-17  8:16   ` Bruce Richardson
2015-07-22 13:54     ` Thomas Monjalon
2015-07-16 23:47 ` [dpdk-dev] [PATCH 2/2] kni: fix coccinelle warnings Stephen Hemminger
2015-07-22 14:25 ` [dpdk-dev] [PATCH 0/2] static matcher cleanups 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).