Re: [PATCH] virtio:linux:kernel:NULL check after kmalloc is needed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Wed, Jan 09, 2019 at 09:30:37AM -0500, Michael S. Tsirkin wrote:
> On Tue, Jan 08, 2019 at 01:40:33PM +0800, Yi Wang wrote:
> > From: "huang.zijiang" <huang.zijiang@xxxxxxxxxx>
> >
> > NULL check is needed because kmalloc maybe return NULL.
> >
> > Signed-off-by: huang.zijiang <huang.zijiang@xxxxxxxxxx>
>
> Can't hurt I will queue it.
>
> > ---
> >  tools/virtio/linux/kernel.h | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/tools/virtio/linux/kernel.h b/tools/virtio/linux/kernel.h
> > index 7ef45a4..2afcad8 100644
> > --- a/tools/virtio/linux/kernel.h
> > +++ b/tools/virtio/linux/kernel.h
> > @@ -65,6 +65,8 @@ static inline void *kzalloc(size_t s, gfp_t gfp)
> >  {
> >  void *p = kmalloc(s, gfp);
> >
> > +if (!p)
> > +return -ENOMEM;
> >  memset(p, 0, s);
> >  return p;
> >  }

Shouldn't this kzalloc() function return NULL in case of error instead of
-ENOMEM?

Best regards,

Vincent.
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
_______________________________________________
Virtualization mailing list
Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/virtualization



[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux