]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
libceph: check kstrndup() return value
authorChengguang Xu <cgxu519@icloud.com>
Fri, 26 Jan 2018 06:54:43 +0000 (14:54 +0800)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 29 Jan 2018 17:36:12 +0000 (18:36 +0100)
Should check result of kstrndup() in case of memory allocation failure.

Signed-off-by: Chengguang Xu <cgxu519@icloud.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
net/ceph/ceph_common.c

index 5c036d2f401e25b42ece6d7cc6c4fc30c00dea43..1e492ef2a33d945699a327831640db04c1f158fa 100644 (file)
@@ -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);