From: Nikolay Aleksandrov <nikolay@redhat.com>
To: Pravin B Shelar <pshelar@nicira.com>, davem@davemloft.net
Cc: netdev@vger.kernel.org, Alex Wang <alexw@nicira.com>
Subject: Re: [PATCH net-next v2 01/11] openvswitch: Allow each vport to have an array of 'port_id's.
Date: Tue, 15 Jul 2014 19:31:04 +0200 [thread overview]
Message-ID: <53C56558.5090404@redhat.com> (raw)
In-Reply-To: <1405444476-16867-1-git-send-email-pshelar@nicira.com>
<snip>
> +/**
> + * ovs_vport_set_upcall_portids - set upcall portids of @vport.
> + *
> + * @vport: vport to modify.
> + * @ids: new configuration, an array of port ids.
> + *
> + * Sets the vport's upcall_portids to @ids.
> + *
> + * Returns 0 if successful, -EINVAL if @ids is zero length or cannot be parsed
> + * as an array of U32.
> + *
> + * Must be called with ovs_mutex.
> + */
> +int ovs_vport_set_upcall_portids(struct vport *vport, struct nlattr *ids)
> +{
> + struct vport_portids *old, *vport_portids;
> +
> + if (!nla_len(ids) || nla_len(ids) % sizeof(u32))
> + return -EINVAL;
> +
> + old = ovsl_dereference(vport->upcall_portids);
> +
> + vport_portids = kmalloc(sizeof(*vport_portids) + nla_len(ids),
> + GFP_KERNEL);
^^^^^^^
Shouldn't there be a null check after the kmalloc instead of directly
dereferencing vport_portids ?
> + vport_portids->n_ids = nla_len(ids) / sizeof(u32);
> + vport_portids->rn_ids = reciprocal_value(vport_portids->n_ids);
> + nla_memcpy(vport_portids->ids, ids, nla_len(ids));
> +
> + rcu_assign_pointer(vport->upcall_portids, vport_portids);
> +
> + if (old)
> + call_rcu(&old->rcu, vport_portids_destroy_rcu_cb);
> +
> + return 0;
> +}
<snip>
next prev parent reply other threads:[~2014-07-15 17:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-15 17:14 [PATCH net-next v2 01/11] openvswitch: Allow each vport to have an array of 'port_id's Pravin B Shelar
2014-07-15 17:31 ` Nikolay Aleksandrov [this message]
2014-07-15 18:16 ` Pravin Shelar
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=53C56558.5090404@redhat.com \
--to=nikolay@redhat.com \
--cc=alexw@nicira.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=pshelar@nicira.com \
/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).