DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH 1/2] rte_ethdev: fix crash if malloc fails in rte_eth_dev_callback_register
Date: Fri, 17 Jul 2015 09:16:03 +0100	[thread overview]
Message-ID: <20150717081603.GB11996@bricha3-MOBL3> (raw)
In-Reply-To: <1437090444-24953-2-git-send-email-stephen@networkplumber.org>

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

  reply	other threads:[~2015-07-17  8:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150717081603.GB11996@bricha3-MOBL3 \
    --to=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).