From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: Maxime Coquelin <maxime.coquelin@redhat.com>
Cc: Jens Freimann <jfreimann@redhat.com>, dev@dpdk.org
Subject: Re: [PATCH] vhost: check malloc return value when allocating guest pages
Date: Mon, 22 May 2017 14:37:59 +0800 [thread overview]
Message-ID: <20170522063759.GN2276@yliu-dev> (raw)
In-Reply-To: <60b35110-df0e-f42b-c331-709b6435f737@redhat.com>
On Thu, May 18, 2017 at 10:14:26AM +0200, Maxime Coquelin wrote:
>
>
> On 05/11/2017 05:25 PM, Jens Freimann wrote:
> >When we try to allocate guest pages we need to check the return value of
> >malloc(). Print an error message and return when it fails.
> >
> >Signed-off-by: Jens Freimann <jfreimann@redhat.com>
> >---
> > lib/librte_vhost/vhost_user.c | 7 +++++++
> > 1 file changed, 7 insertions(+)
> >
> >diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
> >index 5c8058b..437e41f 100644
> >--- a/lib/librte_vhost/vhost_user.c
> >+++ b/lib/librte_vhost/vhost_user.c
> >@@ -515,6 +515,13 @@ vhost_user_set_mem_table(struct virtio_net *dev, struct VhostUserMsg *pmsg)
> > dev->max_guest_pages = 8;
> > dev->guest_pages = malloc(dev->max_guest_pages *
> > sizeof(struct guest_page));
> >+ if (dev->guest_pages == NULL) {
> >+ RTE_LOG(ERR, VHOST_CONFIG,
> >+ "(%d) failed to allocate memory "
> >+ "for dev->guest_pages\n",
> >+ dev->vid);
> >+ return -1;
> >+ }
> > }
> > dev->mem = rte_zmalloc("vhost-mem-table", sizeof(struct rte_vhost_memory) +
> >
>
> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Applied to dpdk-next-virtio.
Thanks.
--yliu
prev parent reply other threads:[~2017-05-22 6:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-11 15:25 [PATCH] vhost: check malloc return value when allocating guest pages Jens Freimann
2017-05-18 8:14 ` Maxime Coquelin
2017-05-22 6:37 ` Yuanhan Liu [this message]
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=20170522063759.GN2276@yliu-dev \
--to=yuanhan.liu@linux.intel.com \
--cc=dev@dpdk.org \
--cc=jfreimann@redhat.com \
--cc=maxime.coquelin@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.