From: Chengguang Xu <cgxu519@icloud.com>
To: ceph-devel@vger.kernel.org
Cc: zyan@redhat.com, sage@redhat.com, davem@davemloft.net,
idryomov@gmail.com, netdev@vger.kernel.org,
Chengguang Xu <cgxu519@icloud.com>
Subject: [PATCH] ceph: Check memory allocation result
Date: Fri, 26 Jan 2018 14:54:43 +0800 [thread overview]
Message-ID: <1516949683-127606-1-git-send-email-cgxu519@icloud.com> (raw)
Should check result of kstrndup() in case of memory allocation failure.
Signed-off-by: Chengguang Xu <cgxu519@icloud.com>
---
net/ceph/ceph_common.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/ceph/ceph_common.c b/net/ceph/ceph_common.c
index 5c036d2..1e492ef 100644
--- a/net/ceph/ceph_common.c
+++ b/net/ceph/ceph_common.c
@@ -421,6 +421,10 @@ struct ceph_options *
opt->name = kstrndup(argstr[0].from,
argstr[0].to-argstr[0].from,
GFP_KERNEL);
+ if (!opt->name) {
+ err = -ENOMEM;
+ goto out;
+ }
break;
case Opt_secret:
opt->key = kzalloc(sizeof(*opt->key), GFP_KERNEL);
--
1.8.3.1
next reply other threads:[~2018-01-26 7:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-26 6:54 Chengguang Xu [this message]
2018-01-29 16:42 ` [PATCH] ceph: Check memory allocation result Ilya Dryomov
2018-01-30 0:08 ` Chengguang Xu
2018-01-30 13:31 ` Ilya Dryomov
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=1516949683-127606-1-git-send-email-cgxu519@icloud.com \
--to=cgxu519@icloud.com \
--cc=ceph-devel@vger.kernel.org \
--cc=davem@davemloft.net \
--cc=idryomov@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=sage@redhat.com \
--cc=zyan@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.