public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@lip6.fr>
To: walter harms <wharms@bfs.de>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	Igor Mammedov <imammedo@redhat.com>,
	kvm@vger.kernel.org, virtualization@lists.linux-foundation.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [patch] vhost: NULL vs ERR_PTR bug
Date: Wed, 15 Jul 2015 10:21:12 -0400 (EDT)	[thread overview]
Message-ID: <alpine.DEB.2.10.1507151020460.2919@hadrien> (raw)
In-Reply-To: <55A64574.1090907@bfs.de>

On Wed, 15 Jul 2015, walter harms wrote:

>
>
> Am 15.07.2015 13:28, schrieb Michael S. Tsirkin:
> > On Wed, Jul 15, 2015 at 02:16:59PM +0300, Dan Carpenter wrote:
> >> There is only one caller for vhost_kvzalloc() and it expects NULL on
> >> allocation failure.  Most people would probably expect that so let's
> >> change ERR_PTR(-ENOMEM) to NULL.
> >>
> >> Fixes: 4de7255f7d2b ('vhost: extend memory regions allocation to vmalloc')
> >> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> >
> > Ouch. Thanks a lot for noticing this, and it's a good thing
> > you did before Linus merged it.
> > I'll squash this into Igor's patch and redo my pull request.
> >
>
> Is this function needed at all ?
>
> e.g. I followed vzalloc() to __vmalloc_node_range()
>
> a check for size==0 seems to be done there.

At least it looks like one could return the result of vzalloc directly?

julia

>
> re,
>  wh
>
>
> >>
> >> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
> >> index a9fe859..99d613b 100644
> >> --- a/drivers/vhost/vhost.c
> >> +++ b/drivers/vhost/vhost.c
> >> @@ -686,7 +686,7 @@ static void *vhost_kvzalloc(unsigned long size)
> >>  	if (!n) {
> >>  		n = vzalloc(size);
> >>  		if (!n)
> >> -			return ERR_PTR(-ENOMEM);
> >> +			return NULL;
> >>  	}
> >>  	return n;
> >>  }
> > --
> > To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

  parent reply	other threads:[~2015-07-15 14:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-15 11:16 [patch] vhost: NULL vs ERR_PTR bug Dan Carpenter
2015-07-15 11:28 ` Michael S. Tsirkin
2015-07-15 11:35   ` walter harms
2015-07-15 11:41     ` Dan Carpenter
2015-07-15 14:21     ` Julia Lawall [this message]
2015-07-15 14:40       ` Dan Carpenter

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=alpine.DEB.2.10.1507151020460.2919@hadrien \
    --to=julia.lawall@lip6.fr \
    --cc=dan.carpenter@oracle.com \
    --cc=imammedo@redhat.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=wharms@bfs.de \
    /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