* Re: [PATCH] virtio:linux:kernel:NULL check after kmalloc is needed
[not found] <1546926033-31684-1-git-send-email-wang.yi59@zte.com.cn>
@ 2019-01-09 14:30 ` Michael S. Tsirkin
[not found] ` <20190109093026-mutt-send-email-mst@kernel.org>
1 sibling, 0 replies; 2+ messages in thread
From: Michael S. Tsirkin @ 2019-01-09 14:30 UTC (permalink / raw)
To: Yi Wang; +Cc: linux-kernel, virtualization, xue.zhihong, huang.zijiang, davem
On Tue, Jan 08, 2019 at 01:40:33PM +0800, Yi Wang wrote:
> From: "huang.zijiang" <huang.zijiang@zte.com.cn>
>
> NULL check is needed because kmalloc maybe return NULL.
>
> Signed-off-by: huang.zijiang <huang.zijiang@zte.com.cn>
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;
> }
> --
> 1.8.3.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] virtio:linux:kernel:NULL check after kmalloc is needed
[not found] ` <20190109093026-mutt-send-email-mst@kernel.org>
@ 2019-01-10 8:13 ` Vincent Stehle
0 siblings, 0 replies; 2+ messages in thread
From: Vincent Stehle @ 2019-01-10 8:13 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Yi Wang, linux-kernel@vger.kernel.org,
virtualization@lists.linux-foundation.org, xue.zhihong@zte.com.cn,
huang.zijiang, davem@davemloft.net
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@zte.com.cn>
> >
> > NULL check is needed because kmalloc maybe return NULL.
> >
> > Signed-off-by: huang.zijiang <huang.zijiang@zte.com.cn>
>
> 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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-01-10 8:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1546926033-31684-1-git-send-email-wang.yi59@zte.com.cn>
2019-01-09 14:30 ` [PATCH] virtio:linux:kernel:NULL check after kmalloc is needed Michael S. Tsirkin
[not found] ` <20190109093026-mutt-send-email-mst@kernel.org>
2019-01-10 8:13 ` Vincent Stehle
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).