libceph: check kstrndup() return value

"Linux Kernel Mailing List" <[email protected]>
Newsgroups gmane.linux.kernel.commits.head
Message-ID <[email protected]>
Web:        https://git.kernel.org/torvalds/c/affff07739392920d3d2095212c72af220481b95
Commit:     affff07739392920d3d2095212c72af220481b95
Parent:     e30ee58121e34831b9665934d70dbc72ab0fe2fb
Refname:    refs/heads/master
Author:     Chengguang Xu <[email protected]>
AuthorDate: Fri Jan 26 14:54:43 2018 +0800
Committer:  Ilya Dryomov <[email protected]>
CommitDate: Mon Jan 29 18:36:12 2018 +0100

    libceph: check kstrndup() return value
    
    Should check result of kstrndup() in case of memory allocation failure.
    
    Signed-off-by: Chengguang Xu <[email protected]>
    Signed-off-by: Ilya Dryomov <[email protected]>
---
 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 5c036d2f401e..1e492ef2a33d 100644
--- a/net/ceph/ceph_common.c
+++ b/net/ceph/ceph_common.c
@@ -421,6 +421,10 @@ ceph_parse_options(char *options, const char *dev_name,
 			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);
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.