linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fuse: fix a NULL pointer dereference
@ 2019-04-29  6:13 zhangliguang
  0 siblings, 0 replies; only message in thread
From: zhangliguang @ 2019-04-29  6:13 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: linux-fsdevel

In case kzalloc fails, the fix returns NULL to avoid NULL pointer
dereference.

Signed-off-by: zhangliguang <zhangliguang@linux.alibaba.com>
---
 fs/fuse/dev.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 9971a35..23e73d8 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -61,6 +61,9 @@ static struct page **fuse_req_pages_alloc(unsigned int npages, gfp_t flags,
 
 	pages = kzalloc(npages * (sizeof(struct page *) +
 				  sizeof(struct fuse_page_desc)), flags);
+	if (!pages)
+		return NULL;
+
 	*desc = (void *) pages + npages * sizeof(struct page *);
 
 	return pages;
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2019-04-29  6:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-29  6:13 [PATCH] fuse: fix a NULL pointer dereference zhangliguang

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).