linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zhiqiang Liu <liuzhiqiang26@huawei.com>
To: <miklos@szeredi.hu>
Cc: <mszeredi@redhat.com>, <linux-fsdevel@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	linfeilong <linfeilong@huawei.com>,
	lihaotian <lihaotian9@huawei.com>
Subject: [PATCH] fuse: check whether fuse_request_alloc returns NULL in fuse_simple_request
Date: Thu, 22 Oct 2020 21:13:00 +0800	[thread overview]
Message-ID: <ffefa3f4-4090-f7dd-97d4-27b8a8cb262f@huawei.com> (raw)


In fuse_simple_request func, we will call fuse_request_alloc func to alloc
one request from fuse_req_cachep when args->force is true. However, the
return value of fuse_request_alloc func is not checked whether it is NULL.
If allocating request fails, access-NULL-pointer problem will occur.

Here, we check the return value of fuse_request_alloc func.

Fixes: 7213394c4e18 ("fuse: simplify request allocation")
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Signed-off-by: Haotian Li <lihaotian9@huawei.com>
---
 fs/fuse/dev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 02b3c36b3676..f7dd33ae8e31 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -481,6 +481,8 @@ ssize_t fuse_simple_request(struct fuse_conn *fc, struct fuse_args *args)
 	if (args->force) {
 		atomic_inc(&fc->num_waiting);
 		req = fuse_request_alloc(GFP_KERNEL | __GFP_NOFAIL);
+		if (!req)
+			return -ENOMEM;

 		if (!args->nocreds)
 			fuse_force_creds(fc, req);
-- 
2.19.1


             reply	other threads:[~2020-10-22 13:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-22 13:13 Zhiqiang Liu [this message]
2020-10-27  9:24 ` [PATCH] fuse: check whether fuse_request_alloc returns NULL in fuse_simple_request Zhiqiang Liu
2020-11-05  1:33 ` Zhiqiang Liu
2020-11-05  2:09   ` Zhiqiang Liu

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=ffefa3f4-4090-f7dd-97d4-27b8a8cb262f@huawei.com \
    --to=liuzhiqiang26@huawei.com \
    --cc=lihaotian9@huawei.com \
    --cc=linfeilong@huawei.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=mszeredi@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 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).